IOS--设计更丰富的界面
生活随笔
收集整理的這篇文章主要介紹了
IOS--设计更丰富的界面
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
?
???
---完成輸入后關(guān)閉鍵盤(pán) 在ViewController.h文件中聲明,放在屬性的下方 - (IBAction)textFiledDoneEditing:(id)sender;切換到ViewController.m,添加代碼- (IBAction)textFiledDoneEditing:(id)sender{[sender resignFirstResponder]; }----通過(guò)觸摸背景關(guān)閉鍵盤(pán), 添加一個(gè)按鈕,讓他填充整個(gè)屏幕, 用戶觸到這個(gè)按鈕就觸發(fā)操作,將nameFiled和numberFiled設(shè)置成第一響應(yīng)狀態(tài) ViewController.h中添加— (IBAction)backgroundClick:(id)sender;在實(shí)現(xiàn)文件中添加:- (IBAction)backgroundClick:(id)sender{[nameFiled resignFirstResponder];[numberFiled resignFirstResponder]; }---實(shí)現(xiàn)滑塊和標(biāo)簽,標(biāo)簽顯示滑塊的值 在.h 文件中聲明一個(gè)輸出口和一個(gè)操作 IBOutlet UILabel *sliderLable;@property (nonatomic, retain) UILable *sliderLable- (IBAction)sliderChanged:(id)sender;切換到.m文件,添加屬性同步 實(shí)現(xiàn)sliderChanged:方法@synthesize sliderLable;- (IBAction)sliderChanged:(id)sender {UISlider *slider = (UISlider *)sender;int progressAsInt = (int)(slider.value + 0.5f);NSString *newText = [[NSString alloc] initWithFormat:@"%d", progressAsInt];sliderLable.text = newText;[newText release]; }----隱藏和顯示多個(gè)控件的最簡(jiǎn)單的方法是, 使用UIView作為需要隱藏或顯示的項(xiàng)的公共父項(xiàng).除了為兩個(gè)開(kāi)關(guān)創(chuàng)建輸出口外,我們還需要為父視圖創(chuàng)建輸出口IBOutlet UISwitch *leftSwitch; IBOutlet UISwitch *rightswitch; IBOutlet UIView *switchView;@property (nonatomic, retain) UISwitch *leftSwitch; @property (nonatomic, retain) UISwitch *rightSwitch; @property (nonatomic, retain) UIView *switchView;-(IBAction)switchChanged:(id)sender; -(IBAction)toggleShowHide:(id)sender;在實(shí)現(xiàn)文件中添加如下代碼 @synthesize leftSwitch; @synthesize rightSwitch; @synthesize switchView;-(IBAction)switchChanged:(id)sender {UISwitch *whichSwich = (UISwitch)sender;BOOL setting = whichSwitch.isOn;[leftSwitch setOn:setting animated:YES];[rightSwitch setOn:setting animated:YES]; }-(IBAction)toggleShowHide:(id)sender {UISegmentedControl *segmentedControl = (UISegmentedControl *)sender;NSInteger segment = segmentedControl.selectedSegmentIndex;if(segment == 0) [switchView setHidden:ON];else [switchView seHidden:YES]; }
?
轉(zhuǎn)載于:https://www.cnblogs.com/ShlodenZhang/archive/2013/06/06/3120848.html
總結(jié)
以上是生活随笔為你收集整理的IOS--设计更丰富的界面的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: ubuntu 13.04 设置Dash中
- 下一篇: .net之workFlow4.0学习