亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 學院 > 開發設計 > 正文

IOS開發基礎知識--碎片17

2019-11-14 18:45:33
字體:
來源:轉載
供稿:網友

 

1:contentSize、contentInset和contentOffset區別

contentSize 是scrollview中的一個屬性,它代表scrollview中的可顯示區域,假如有一個scrollview,它的frame為(0,0,320,480),而它的contentSize為(320,960).也就是說,這個scrollview整個內容的大小為(320,960),要通過上下滑動scrollview來查看(320,480)后的內容。contentOffset 是scrollview當前顯示區域頂點相對于frame頂點的偏移量,比如上個例子你拉到最下面,contentoffset就是(0 ,-480),也就是y偏移了480contentInset 是scrollview中contentView.frame.origin與scrollview.frame.origin的關系,比如contentView的frame為(0,30,320,480),那么contentInset則為(0, 30),它也可以設置上下左右

 

2:IOS虛擬器安裝其它Simulator

下載后的dmg安裝.這里主要以iOS7.0模擬器的離線安裝為例進行說明,其他版本以此類推:下載ios_7_0_simulator.dmg后打開dmg文件,可以看到安裝包iphoneSimulatorSDK7_0.pkg,使用安裝器安裝此安裝包,默認會安裝在所選分區的/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk目錄下,完全退出Xcode后將剛才安裝的iPhoneSimulator7.0.sdk整個目錄復制或移動到/applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs目錄下即可,(Xcode.app右鍵可以"顯示包內容“)重新啟動Xcode一般就可以使用相應版本的模擬器進行開發和調試了。離線安裝還有一個簡單的辦法就是將以前安裝過的舊版本的Xcode如Xcode5.0.2下面已經安裝好了的iOS模擬器直接復制過來使用,目錄位置都一樣,都是在Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs里面。這樣就不用再下載離線安裝包了。

 

3:輸入框中的inputaccessoryview和inputview

UITextFields和UITextView有一個inputAccessoryView的屬性,當你想在鍵盤上展示一個自定義的view時,你就可以設置該屬性。你設置的view就會自動和鍵盤keyboard一起顯示了。需要注意的是,你所自定義的view既不應該處在其他的視圖層里,也不應該成為其他視圖的子視圖。其實也就是說,你所自定義的view只需要賦給屬性inputAccessoryView就可以了,不要再做其他多余的操作。inputview則是鍵盤視圖,當其為nil時則彈出的是系統默認的鍵盤;實例一(給鍵盤上方設置一個工具條的方式):- (void)createKeyboardTool{    keyboardTool = [[UIToolbar alloc] initWithFrame: CGRectMake(kZero, kZero, kScreenW, 44.0f)];    NSMutableArray *myToolBarItems = [NSMutableArray array];  //創建鍵盤工具條上面的按鈕,并設置點擊事件    UIBarButtonItem *cancelBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemReply target:self action:@selector(cancelAction)];    UIBarButtonItem *space = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:@selector(saveAction)];    UIBarButtonItem *saveBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(saveAction)];        [myToolBarItems addObject:cancelBtn];    [myToolBarItems addObject:space];    [myToolBarItems addObject:saveBtn];    keyboardTool.items = myToolBarItems;}//inputAccessoryView:設置鍵盤頂部顯示的工具條;inputView:自定義鍵盤    commentTextView = [[UITextView alloc]initWithFrame:CGRectMake(kZero, kZero, kScreenW, 200)];    [commentTextView becomeFirstResponder];    commentTextView.inputAccessoryView = keyboardTool;實例二(修改鍵盤視圖,進行切換自定義視圖跟系統自帶視圖):/** *  切換鍵盤 */- (void)switchKeyboard{    // self.textView.inputView == nil : 使用的是系統自帶的鍵盤    if (self.textView.inputView == nil) {        // 切換為自定義的表情鍵盤 emtionKeyboard為一個視圖        self.textView.inputView = self.emotionKeyboard;        // 顯示鍵盤按鈕        self.toolbar.showKeyboardButton = YES;    } else {         // 切換為系統自帶的鍵盤        self.textView.inputView = nil;        // 顯示表情按鈕        self.toolbar.showKeyboardButton = NO;    }    // 開始切換鍵盤 這個是為固定用的    self.switchingKeybaord = YES;        // 退出鍵盤    [self.textView endEditing:YES];        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{        // 彈出鍵盤,讓其慢點實現         [self.textView becomeFirstResponder];                // 結束切換鍵盤        self.switchingKeybaord = NO;    });}/** * 鍵盤的frame發生改變時調用(顯示、隱藏等) */- (void)keyboardWillChangeFrame:(NSNotification *)notification{    // 如果正在切換鍵盤,就不要執行后面的代碼    if (self.switchingKeybaord) return;        NSDictionary *userInfo = notification.userInfo;    // 動畫的持續時間    double duration = [userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];    // 鍵盤的frame    CGRect keyboardF = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];        // 執行動畫    [UIView animateWithDuration:duration animations:^{        // 工具條的Y值 == 鍵盤的Y值 - 工具條的高度        if (keyboardF.origin.y > self.view.height) { // 鍵盤的Y值已經遠遠超過了控制器view的高度            self.toolbar.y = self.view.height - self.toolbar.height;        } else {            self.toolbar.y = keyboardF.origin.y - self.toolbar.height;        }    }];}

 

4:修改UISearchBar中關于cannel取消的文字

-(UISearchBar *)mySearchBar{    if (_mySearchBar==nil) {        _mySearchBar=[[UISearchBar alloc]init];        _mySearchBar.showsCancelButton=YES;        _mySearchBar.delegate=self;        [_mySearchBar sizeToFit];        [_mySearchBar setPlaceholder:@"請輸入"];        [_mySearchBar setY:20];                //處理cannel的文字顯示        for (id item in [_mySearchBar subviews]) {            for(id cc in [item subviews])            {                if ([cc isKindOfClass:[UIButton class]]) {                    UIButton *btn=(UIButton *)cc;                    [btn setTitle:@"取消" forState:UIControlStateNormal];                }            }        }    }    return _mySearchBar;}如果是獲得瞧點才顯示出取消可以在這個委托里面進行設置:/** *  @author wujunyang, 15-06-24 11:06:44 * *  @brief  修改cancel的顯示文字 必先把showscancelButton設置為yes *  @param searchBar <#searchBar description#> */- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar{    searchBar.showsCancelButton=YES;    for (id item in [searchBar subviews]) {        for(id cc in [item subviews])        {        if ([cc isKindOfClass:[UIButton class]]) {            UIButton *btn=(UIButton *)cc;            [btn setTitle:@"取消" forState:UIControlStateNormal];        }        }    }}

 

5:關于navigationController中增加控件時push跳轉及跳回

在子頁navigationController增加控件,回跳時它是沒辦法自個銷除,所以要手動增加一個銷除nav所增加的控件,否則子頁的那個控件會被重疊顯示在父頁的nav上;如下一個實例:在viewDidLoad里//加載控件    [self.navigationController.view addSubview:self.mySearchBar];(void)viewWillDisappear:(BOOL)animated {    //這句也可以寫在回跳前    [self.mySearchBar removeFromSuperview];    [super viewWillDisappear:animated];}

 

6:整個視圖點擊都對鍵盤進行收縮

- (void)viewDidLoad {    [super viewDidLoad];    UITapGestureRecognizer *tapGr=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewTapped:)];    //如果沒有這句在view中的Button等可能無法觸發ToucheUpInside事件    tapGr.cancelsTouchesInView=NO;    [self.view addGestureRecognizer:tapGr];}- (IBAction)BtnAction:(id)sender {    NSLog(@"%@",self.myTextField.text);}-(void)viewTapped:(UITapGestureRecognizer *)tapGr{    [self.myTextField resignFirstResponder];}- (void)didReceiveMemoryWarning {    [super didReceiveMemoryWarning];}@end

 

7:針對第三方插件為mrc,而工程為arc的調用

對第三方插件的.m文件進行設置,工程targets-build phases-compile sources 設置-fno-objc-arc有些是雙星如 PLTexture **PReviewTextures; 在arc下面則要修改成:PLTexture * __unsafe_unretained *previewTextures;

 

8:通知的方式實現鍵盤的收縮布局問題

/** *  添加工具條 */- (void)setupToolbar{    // 1.添加工具條    IWComposeToolbar *toolbar = [[IWComposeToolbar alloc] init];    toolbar.delegate = self;    CGFloat toolbarH = 35;    CGFloat toolbarW = self.view.width;    CGFloat toolbarY = self.view.height - toolbarH;    toolbar.frame = CGRectMake(0, toolbarY, toolbarW, toolbarH);    [self.view addSubview:toolbar];    self.toolbar = toolbar;        // 2.監聽鍵盤的彈出和隱藏    // 鍵盤的frame(位置)即將改變, 就會發出UIKeyboardWillChangeFrameNotification    // 鍵盤即將彈出, 就會發出UIKeyboardWillShowNotification    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];    // 鍵盤即將隱藏, 就會發出UIKeyboardWillHideNotification    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];}#pragma mark - 鍵盤處理/** *  鍵盤即將隱藏 */- (void)keyboardWillHide:(NSNotification *)note{    // 1.鍵盤彈出需要的時間    CGFloat duration = [note.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];        // 2.動畫    [UIView animateWithDuration:duration animations:^{        self.toolbar.transform = CGAffineTransformIdentity;    }];}/** *  鍵盤即將彈出 */- (void)keyboardWillShow:(NSNotification *)note{    // 1.鍵盤彈出需要的時間    CGFloat duration = [note.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];        // 2.動畫    [UIView animateWithDuration:duration animations:^{        // 取出鍵盤高度        CGRect keyboardF = [note.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];        CGFloat keyboardH = keyboardF.size.height;        self.toolbar.transform = CGAffineTransformMakeTranslation(0, - keyboardH);    }];}//通知要銷掉- (void)dealloc{    [[NSNotificationCenter defaultCenter] removeObserver:self];}注意:[self.textView resignFirstResponder];放棄瞧點還有可以監聽輸入內容的變化:    // 2.監聽textView文字的改變    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textChange) name:UITextViewTextDidChangeNotification object:textView];

 

9:封裝一個uivew帶有按鍵工具欄的實例

.h文件內容:#import <UIKit/UIKit.h>@class IWComposeToolbar;typedef enum {    IWComposeToolbarButtonTypeCamera,    IWComposeToolbarButtonTypePicture,    IWComposeToolbarButtonTypeMention,    IWComposeToolbarButtonTypeTrend,    IWComposeToolbarButtonTypeEmotion} IWComposeToolbarButtonType;@protocol IWComposeToolbarDelegate <NSObject>@optional- (void)composeToolbar:(IWComposeToolbar *)toolbar didClickButton:(IWComposeToolbarButtonType)butonType;@end@interface IWComposeToolbar : UIView@property (weak, nonatomic) id<IWComposeToolbarDelegate> delegate;@end.m文件內容:#import "IWComposeToolbar.h"@implementation IWComposeToolbar- (id)initWithFrame:(CGRect)frame{    self = [super initWithFrame:frame];    if (self) {        // 1.設置背景        self.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageWithName:@"compose_toolbar_background"]];                // 2.添加按鈕        [self addButtonWithIcon:@"compose_camerabutton_background" highIcon:@"compose_camerabutton_background_highlighted" tag:IWComposeToolbarButtonTypeCamera];        [self addButtonWithIcon:@"compose_toolbar_picture" highIcon:@"compose_toolbar_picture_highlighted" tag:IWComposeToolbarButtonTypePicture];        [self addButtonWithIcon:@"compose_mentionbutton_background" highIcon:@"compose_mentionbutton_background_highlighted" tag:IWComposeToolbarButtonTypeMention];        [self addButtonWithIcon:@"compose_trendbutton_background" highIcon:@"compose_trendbutton_background_highlighted" tag:IWComposeToolbarButtonTypeTrend];        [self addButtonWithIcon:@"compose_emoticonbutton_background" highIcon:@"compose_emoticonbutton_background_highlighted" tag:IWComposeToolbarButtonTypeEmotion];    }    return self;}- (void)addButtonWithIcon:(NSString *)icon highIcon:(NSString *)highIcon tag:(IWComposeToolbarButtonType)tag{    UIButton *button = [[UIButton alloc] init];    button.tag = tag;    [button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];    [button setImage:[UIImage imageWithName:icon] forState:UIControlStateNormal];    [button setImage:[UIImage imageWithName:highIcon] forState:UIControlStateHighlighted];    [self addSubview:button];}/** *  監聽按鈕點擊 */- (void)buttonClick:(UIButton *)button{    if ([self.delegate respondsToSelector:@selector(composeToolbar:didClickButton:)]) {        [self.delegate composeToolbar:self didClickButton:button.tag];    }}- (void)layoutSubviews{    [super layoutSubviews];        int count = self.subviews.count;    CGFloat buttonW = self.width / count;    CGFloat buttonH = self.height;    for (int i = 0; i<count; i++) {        UIButton *button = self.subviews[i];        CGFloat buttonX = buttonW * i;        button.frame = CGRectMake(buttonX, 0, buttonW, buttonH);    }}@end

 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
亚洲精品中文字幕女同| 久久6免费高清热精品| www.亚洲人.com| 成人亚洲欧美一区二区三区| 国产极品精品在线观看| 欧美成人精品不卡视频在线观看| 91精品美女在线| 91影院在线免费观看视频| 青青久久av北条麻妃黑人| 伊人亚洲福利一区二区三区| 91精品国产乱码久久久久久蜜臀| 久久香蕉国产线看观看网| 国产拍精品一二三| 91视频8mav| 欧美资源在线观看| 成人写真视频福利网| 91中文在线视频| 日本一区二区三区在线播放| 国产一区二区三区久久精品| 欧美日韩亚洲精品内裤| 亚洲美女视频网站| 一区二区三区国产在线观看| 日本一区二区在线播放| 日韩精品亚洲精品| 欧美成人精品在线观看| 91av福利视频| 国产美女精品视频| 成人综合国产精品| 韩日精品中文字幕| 欧美超级乱淫片喷水| 色偷偷噜噜噜亚洲男人| 中文字幕亚洲综合久久筱田步美| 97色在线视频| 亚洲人成在线一二| 亚洲人成网7777777国产| 国产精品高清在线观看| 国内免费精品永久在线视频| 欧美日韩国产中字| 国产精品久久久久久久久久久久久| 亚洲电影免费观看高清完整版在线| 日本aⅴ大伊香蕉精品视频| 日本最新高清不卡中文字幕| 97激碰免费视频| 亚洲图片在区色| 亚洲美女免费精品视频在线观看| 蜜月aⅴ免费一区二区三区| 欧美老妇交乱视频| 国产精品专区一| 亚洲影院色在线观看免费| 欧美韩日一区二区| 在线视频国产日韩| 国产欧美在线观看| 欧美激情视频播放| 国产精品福利无圣光在线一区| 精品视频在线播放| 中文字幕久热精品在线视频| 91精品在线观看视频| 欧美亚州一区二区三区| 欧洲成人免费aa| 久久久国产在线视频| 91免费精品视频| 成人网页在线免费观看| 日韩在线观看免费高清完整版| 91精品久久久久久综合乱菊| 亚洲一区二区三区成人在线视频精品| 成人激情视频小说免费下载| 国产主播精品在线| 国产日韩在线亚洲字幕中文| 伊人伊成久久人综合网站| 久久99青青精品免费观看| 国产成人精品一区| 日韩中文字幕国产| 色综合久久中文字幕综合网小说| 伊人精品在线观看| 欧美激情一级精品国产| 国产美女直播视频一区| 555www成人网| 日韩av观看网址| 欧美日韩国产影院| 国产精品一区二区性色av| 国产专区欧美专区| 欧美激情久久久久久| 欧美有码在线视频| 中文字幕免费精品一区高清| 久久天天躁狠狠躁夜夜躁| 亚洲国产美女精品久久久久∴| 欧美激情视频三区| 麻豆国产精品va在线观看不卡| 成人国产精品久久久久久亚洲| 久久久久久国产三级电影| 国产精品视频专区| 欧美成人精品在线播放| 欧美中文字幕在线观看| 一本色道久久88综合日韩精品| 国产精品劲爆视频| 欧美性猛交xxxx黑人| 亚洲成色777777在线观看影院| 精品久久久久久久久久久久久| 98精品国产自产在线观看| 成人夜晚看av| 日韩免费看的电影电视剧大全| 日本欧美一级片| 91系列在线观看| 精品夜色国产国偷在线| 色综合久综合久久综合久鬼88| 国产精品久久在线观看| 性欧美xxxx视频在线观看| 国产精品亚洲片夜色在线| 国产成人精品免费久久久久| 97免费中文视频在线观看| 中文字幕亚洲第一| 国产欧美一区二区三区在线看| 国产一区二区久久精品| 亚洲最大福利视频网| 亚洲男人天天操| 日韩在线视频线视频免费网站| 欧美孕妇与黑人孕交| 爽爽爽爽爽爽爽成人免费观看| 国产精品一区二区久久久久| 久久国产精彩视频| 国产精品一区二区av影院萌芽| 日韩视频精品在线| 97超级碰碰碰久久久| 亚洲美女av黄| 亚洲欧洲国产精品| 亚洲国产女人aaa毛片在线| 深夜精品寂寞黄网站在线观看| 在线精品播放av| 欧美一级视频免费在线观看| 精品亚洲男同gayvideo网站| 热久久视久久精品18亚洲精品| 亚洲xxxx在线| 午夜剧场成人观在线视频免费观看| 日本高清不卡在线| 日韩欧美视频一区二区三区| 成人网页在线免费观看| 亚洲va国产va天堂va久久| 一区二区三区视频免费在线观看| 欧美午夜片欧美片在线观看| 亚洲欧洲在线免费| 国产午夜精品久久久| 久久精品2019中文字幕| 欧美激情国产日韩精品一区18| 午夜精品福利视频| 亚洲天堂成人在线视频| 欧美诱惑福利视频| 欧美精品videos性欧美| 97碰碰碰免费色视频| 美女国内精品自产拍在线播放| 日本不卡高字幕在线2019| 日韩专区中文字幕| 国产精品嫩草影院一区二区| 青草青草久热精品视频在线网站| 欧美视频在线观看免费网址| 国外成人性视频| 欧美亚洲第一区| 91探花福利精品国产自产在线| 久久久www成人免费精品| 亚州欧美日韩中文视频| 国产精品久久久久久av| 欧美黄色性视频| 亚洲福利在线视频| 亚洲福利精品在线| 成人性教育视频在线观看|