国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

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

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

2019-11-14 19:31:29
字體:
來源:轉載
供稿:網友

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

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

2:AFnetWorking報"Request failed: unacceptable content-type: text/html"

對應到自己的項目里面,我用的是AFNetworking這套網絡請求包,需要改的是:AFURLResponseSerialization.m文件223行:self.acceptableContentTypes = [NSSetsetWithObjects:@"application/json", @"text/html",@"text/json",@"text/javascript", nil];加上@"text/html",部分,其實就是添加一種服務器返回的數據格式。

3:NSMutableArray和NSArray的相互轉換

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

4:自定義系統導航條上面的返回按鈕,以及文字,右側收藏按鈕

 //中間標題   UILabel *navLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];   navLabel.text = @"團購詳情";   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;導航條上的title字體, 字號 可以這么定義,完全使用系統的 [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跳轉后的頭部右鍵

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

7:如要給UICollectionViewController視圖設置背景圖

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:新浪微博授權登錄報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跳轉到b,然后b放一個授權新浪微博的按鍵,增加一個UINavigationController,然后在a跳轉到b時用nav跳轉:    UIStoryboard *mainStoryboard=[UIStoryboard storyboardWithName:@"Main" bundle:nil];    LoginViewController* loginviewControll=[mainStoryboard instantiateViewControllerWithIdentifier:@"loginviewcontroller"];    [self.navigationController pushViewController:loginviewControll  animated:YES];

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

是因為重復引入libTCWeiboSDK這個類庫,TARGETS-PROJECT-Build Phases-Link Binary With Libraries中,有三個libTcweiboSDK,可以刪除libTCWeiboSDK-I386.a

11:NSUserDefaults存放民NSDictionary

注意:NSUserDefaults支持的數據類型有NSString、 NSNumber、NSDate、 NSArray、NSDictionary、BOOL、NSInteger、NSFloat等系統定義的數據類型。本次遇到的問題:當NSDictionary里面的值為null時,要寫入NSUserDefaults會報異常(attempt to insert non-property list object);解決方式:把字典中的值進行過濾處理,為空的轉化成字符串的空值;代碼如下(創建一個擴展類):@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

 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 紫阳县| 垦利县| 桓仁| 通山县| 石渠县| 宝鸡市| 罗源县| 荆州市| 富蕴县| 阳泉市| 福州市| 邵武市| 上饶县| 丰县| 阿鲁科尔沁旗| 辽中县| 青海省| 鹤庆县| 临桂县| 墨竹工卡县| 安顺市| 东至县| 湘潭县| 宝清县| 南靖县| 新化县| 绿春县| 中山市| 南投市| 潼南县| 古蔺县| 和龙市| 云和县| 手游| 双桥区| 两当县| 汕尾市| 隆子县| 满城县| 维西| 武功县|