UI第五節 手勢

2022-06-12 14:39:08 字數 2142 閱讀 4596

@end

self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]];

self.window.backgroundcolor = [uicolor whitecolor];

self.window.rootviewcontroller = [uiviewcontroller new];

[self.window makekeyandvisible];

#if 0

//點選手勢

uitapgesturerecognizer *tap = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(myges:)];

//雙擊

tap.numberoftapsrequired = 2;

//把點選手勢新增到self.window之上

[self.window addgesturerecognizer:tap];

#endif

#if 0

//放大縮小手勢

uipinchgesturerecognizer *pinch = [[uipinchgesturerecognizer alloc] initwithtarget:self action:@selector(myges:)];

[self.window addgesturerecognizer:pinch];

#endif

#if 0

//旋轉手勢

uirotationgesturerecognizer *rotation = [[uirotationgesturerecognizer alloc] initwithtarget:self action:@selector(myges:)];

[self.window addgesturerecognizer:rotation];

#endif

#if 0

//滑動手勢

uiswipegesturerecognizer *swi = [[uiswipegesturerecognizer alloc] initwithtarget:self action:@selector(myges:)];

//僅支援水平或者豎直方向其中的一種,以支援水平方向為主

swi.direction = uiswipegesturerecognizerdirectiondown | uiswipegesturerecognizerdirectionup;

[self.window addgesturerecognizer:swi];

#endif

#if 0

//拖動手勢

uipangesturerecognizer *pan = [[uipangesturerecognizer alloc] initwithtarget:self action:@selector(myges:)];

[self.window addgesturerecognizer:pan];

#endif

//長按手勢

uilongpressgesturerecognizer *longpress = [[uilongpressgesturerecognizer alloc] initwithtarget:self action:@selector(myges:)];

//2秒之後響應

= 2.0f;

[self.window addgesturerecognizer:longpress];

/*注意:

1.要uiview物件可以響應事件,前提是uiview的userinteractionenabled屬性要設定為yes

2.uilabel和uiimageview這個兩個類例項化出來的物件,預設userinteractionenabled的屬性值為no

3.檢視被隱藏之後,也無法響應事件

4.如果父檢視的userinteractionenabled的屬性值為no,所有的子檢視也一併無法響應事件

*/self.window.userinteractionenabled = no;

return yes;

}//宣告乙個方法,處理手勢事件

-(void)myges:(uigesturerecognizer *)ges

函式第五節

coding utf 8 1.定義乙個func name 該函式效果如下。assert func lilei lilei assert func hanmeimei hanmeimei assert func hanmeimei hanmeimei def title name if isinsta...

第五節 字典

字典的表現形式為大括號 dict key必須可hash,必須唯一且必須為不可改變的資料型別 value可存放任意多個值,可修改,可不唯一 無序且查詢速度快 鍵 值 鍵值對 1 dic.keys 返回乙個包含字典所有key的列表 2 dic.values 返回乙個包含字典所有value的列表 3 di...

第五節 列表(list)

lpush listname value lpush 命令將乙個或多個值插入到列表頭部。lpush newlist valuea valueb lindex listname index 佇列從做往右,索引從0開始。隊頭在左邊,新插入的元素就是索引為0的元素。你也可以使用負數下標,以 1 表示列表的...