麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁(yè) > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

IOS開發(fā)基礎(chǔ)知識(shí)--碎片8

2019-11-14 19:31:29
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

1:用UIImageView作為背景,但直接把按鈕或者UITextField放在上面無(wú)法相應(yīng)事件。

解決辦法:UIImageView默認(rèn)的UserInteractionEnabled是NO,把它修改成YES,或者可以直接在XCODE上面的view有個(gè)屬性勾選User Interaction Enabled遇到的場(chǎng)景(在滾動(dòng)視圖里面放一個(gè)圖片視圖,在圖片視圖上又放置一個(gè)按鍵,發(fā)現(xiàn)一直沒有響應(yīng)效果);

2:AFnetWorking報(bào)"Request failed: unacceptable content-type: text/html"

對(duì)應(yīng)到自己的項(xiàng)目里面,我用的是AFNetworking這套網(wǎng)絡(luò)請(qǐng)求包,需要改的是:AFURLResponseSerialization.m文件223行:self.acceptableContentTypes = [NSSetsetWithObjects:@"application/json", @"text/html",@"text/json",@"text/javascript", nil];加上@"text/html",部分,其實(shí)就是添加一種服務(wù)器返回的數(shù)據(jù)格式。

3:NSMutableArray和NSArray的相互轉(zhuǎn)換

// NSArray --> NSMutableArray  NSMutableArray *myMutableArray = [myArray mutableCopy];  // NSMutableArray --> NSArray  NSArray *myArray = [myMutableArray copy];  

4:自定義系統(tǒng)導(dǎo)航條上面的返回按鈕,以及文字,右側(cè)收藏按鈕

 //中間標(biāo)題   UILabel *navLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];   navLabel.text = @"團(tuán)購(gòu)詳情";   navLabel.textColor = [UIColor whiteColor];   navLabel.font = [UIFont systemFontOfSize:18];   navLabel.textAlignment = NSTextAlignmentCenter;   self.navigationItem.titleView = navLabel;       //右邊收藏按鈕   UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom];   rightButton.frame = CGRectMake(0, 0, 20, 20);   [rightButton setBackgroundImage:LOAD_IMAGE(@"meishoucang") forState:UIControlStateNormal];   [rightButton addTarget:self action:@selector(doShouCang) forControlEvents:UIControlEventTouchUpInside];   UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:rightButton];   self.navigationItem.rightBarButtonItem = rightItem;       //左邊返回按鈕   UIButton *fanHuiButton = [UIButton buttonWithType:UIButtonTypeCustom];   fanHuiButton.frame = CGRectMake(0, 0, 30, 40);   [fanHuiButton setBackgroundImage:LOAD_IMAGE(@"fanhuijiantou") forState:UIControlStateNormal];   [fanHuiButton addTarget:self action:@selector(doFanHui) forControlEvents:UIControlEventTouchUpInside];   UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:fanHuiButton];   self.navigationItem.leftBarButtonItem = leftItem;導(dǎo)航條上的title字體, 字號(hào) 可以這么定義,完全使用系統(tǒng)的 [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:       [UIColor colorWithRed:1.0/255 green:1.0/255 blue:1.0/255 alpha:1], UITextAttributeTextColor,[UIColor clearColor],UITextAttributeTextShadowColor,[UIFont systemFontOfSize:20],UITextAttributeFont,nil]];

5:清理UITableView底部空的列

self.tableView.tableFooterView = [[UIView alloc] init];

 6:如何隱藏navigation跳轉(zhuǎn)后的頭部右鍵

//隱藏頭部左邊的返回self.navigationItem.hidesBackButton=YES;//隱藏頭部右邊self.navigationItem.rightBarButtonItem.customView.hidden=YES;

7:如要給UICollectionViewController視圖設(shè)置背景圖

UIImage *image=[UIImage imageNamed:@"AppBg"];self.collectionView.layer.contents=(id)image.CGImage;

8:可以在其它地方修改rootViewController

UIWindow *window = [UIApplication sharedApplication].keyWindow;    window.rootViewController = [[HVWTabBarViewController alloc] init];

9:新浪微博授權(quán)登錄報(bào)Warning: Attempt to PResent on whose view is not in the window hierarchy!

 IntroductoryViewController *introductory=[mainStoryboard instantiateViewControllerWithIdentifier:@"introductoryview"];        UINavigationController *rootNavigationController=[[UINavigationController alloc] initWithRootViewController:introductory];            self.window.rootViewController=rootNavigationController;主要問題是a跳轉(zhuǎn)到b,然后b放一個(gè)授權(quán)新浪微博的按鍵,增加一個(gè)UINavigationController,然后在a跳轉(zhuǎn)到b時(shí)用nav跳轉(zhuǎn):    UIStoryboard *mainStoryboard=[UIStoryboard storyboardWithName:@"Main" bundle:nil];    LoginViewController* loginviewControll=[mainStoryboard instantiateViewControllerWithIdentifier:@"loginviewcontroller"];    [self.navigationController pushViewController:loginviewControll  animated:YES];

10:在引入第三方TcweiboSDK報(bào)linker command failed with exit code1(use -v to see invocation)

是因?yàn)橹貜?fù)引入libTCWeiboSDK這個(gè)類庫(kù),TARGETS-PROJECT-Build Phases-Link Binary With Libraries中,有三個(gè)libTcweiboSDK,可以刪除libTCWeiboSDK-I386.a

11:NSUserDefaults存放民NSDictionary

注意:NSUserDefaults支持的數(shù)據(jù)類型有NSString、 NSNumber、NSDate、 NSArray、NSDictionary、BOOL、NSInteger、NSFloat等系統(tǒng)定義的數(shù)據(jù)類型。本次遇到的問題:當(dāng)NSDictionary里面的值為null時(shí),要寫入NSUserDefaults會(huì)報(bào)異常(attempt to insert non-property list object);解決方式:把字典中的值進(jìn)行過濾處理,為空的轉(zhuǎn)化成字符串的空值;代碼如下(創(chuàng)建一個(gè)擴(kuò)展類):@implementation NSDictionary(Common)-(NSDictionary *) changeDictionaryNotNill{    NSMutableDictionary *muResult=[[NSMutableDictionary alloc]init];    NSEnumerator *enumerator=[self keyEnumerator];    id key;    while ((key=[enumerator nextObject])) {        id value=[self objectForKey:key];        if ((NSNull *)value==[NSNull null]) {            [muResult setObject:@"" forKey:key];        }        else        {            [muResult setObject:value forKey:key];        }    }    return muResult;}@end

 


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 国产亚洲精品综合一区91 | 蜜桃一本色道久久综合亚洲精品冫 | 成人在线观看一区二区 | 九九色在线观看 | 国产91极品 | 精品国产一区二区在线观看 | 精品xxxx户外露出视频 | 国产a级久久 | 免费毛片在线 | 视频一区二区中文字幕 | 久久久久久久久久久av | 免费h片网站 | 免费黄色在线观看网站 | 成人在线观看免费爱爱 | 人人看人人艹 | 爱射av | 日本在线视频一区二区三区 | 伊人av影院| 国产精品99精品 | 一区二区三高清 | 中国a毛片| 一级黄色毛片播放 | 国产日韩在线观看一区 | 国产在线免费 | sese综合 | 精品人人人人 | 亚洲国产精品久久久久久久久 | 亚洲成人伊人 | 精品国产一区二区三区久久久狼牙 | 欧美精品18 | 国产瑟瑟视频 | 伊人yinren22综合网色 | 国产欧美精品综合一区 | 蜜桃欧美性大片免费视频 | 成av在线| 色妞欧美 | 久久精品视频亚洲 | 新久草在线视频 | 久久99精品国产99久久6男男 | 国产成人av免费看 | 成人三级电影在线 |