Notes

★ Core Data
[[NSManagedObjectModel alloc] initWithContentsOfURL:momURL]  VS [[NSManagedObjectModel mergedModelFromBundles:nil] retain]
appDelegate.moc


★ appDelegate实例
CEIBSAppDelegate *appDelegate = (CEIBSAppDelegate *)[UIApplication sharedApplication].delegate;


★ COLOR设置
COLOR(180,18,21)
#define TITLESTYLE_COLOR  COLOR(180,18,21)
[UIColor clearColor]
[UIColor whiteColor]


★ Save
- (void)saveLoadAlumniInfoCount:(NSInteger)count {
    [[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithFormat:@"%d", count]
                                              forKey:LOAD_ALUMNI_INFO];
    [[NSUserDefaults standardUserDefaults] synchronize];
}


★ EXC_BAD_ACCESS
Case 1:
release了需要调用的对象,关键是定位。
CEIBS[2057:707] *** -[CFLocale release]: message sent to deallocated instance 0x399920


1,设置Product -> Edit Scheme -> Environment Variables

NSZombieEnabled YES

MallocStackLogging YES

NSAutoreleaseFreedObjectCheckEnabled

NSDebugEnabled



2,终端查看
malloc_history ${App_PID} ${Object_instance_addr}
malloc_history 2057:707 0x399920


查找0x399920 寻找相关代码


3,如果还不能找到,采用下面
#ifdef _FOR_DEBUG_
-(BOOL) respondsToSelector:(SEL)aSelector {
    printf("SELECTOR: %s\n", [NSStringFromSelector(aSelector) UTF8String]);
    return [super respondsToSelector:aSelector];
}
#endif


需要在每个object的.m或者.mm文件中加入上面代码,并且在
other c flags中加入-D _FOR_DEBUG_(记住只在Debug Configuration下加入此标记)。
这样当你程序崩溃时,Xcode的console上就会准确地记录了最后运行的object的方法。


★ 背景渐变
bg.png为背景渐变的图片。
view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg.png"]];


★  静态库调用
USER_HEADER_SEARCH_PATHS = /Users/Adam/Documents/TestLibrary/TestLibrary/**


★  Tableview 没有值

numberOfRowsInSection 打印值,如果没有就是TableView没有初始化。


★  viewDidAppear调用
5.0以后会自动调用,4.3需要强制调用。


 Crash

Organizer -> Console

Mar 28 16:36:25 unknown iAlumni[1856] : *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Cannot create an NSPersistentStoreCoordinator with a nil model'


 Login的独立

//- (void)openLogin

//{

//    

//    LoginViewController *mLoginController = [[[LoginViewController alloc] initWithMOC:managedObjectContext] autorelease];

//    homeNavVC.navigationBar.tintColor = TITLESTYLE_COLOR;

// [homeNavVC presentModalViewController:mLoginController animated:YES];

//    

//}


- (void)openLogin

{   

    LoginViewController *mLoginController = [[LoginViewController alloc] initWithMOC:managedObjectContext];

    UINavigationController *homeNav = [[UINavigationController alloc] initWithRootViewController:mLoginController];

    self.window.rootViewController = homeNav;

    homeNav.navigationBarHidden = YES;

    [self.window makeKeyAndVisible];

[self.window addSubview:homeNav.view];

    RELEASE_OBJ(mLoginController);

    RELEASE_OBJ(homeNav);

}


 void SendDelegateMessage(NSInvocation*): delegate (webView:decidePolicyForNavigationAction:request:frame:decisionListener:) failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode


 Apr  6 18:32:59 unknown iAlumni[80] : *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Cannot create an NSPersistentStoreCoordinator with a nil model'


★  单个navigationController回到主界面

[self.navigationController popToRootViewControllerAnimated:YES];


★  真机调试

error: failed to launch '/Users/Adam/Library/Developer/Xcode/DerivedData/iAlumni-evlhawkehmiqrzacwjvtozfzhkcx/Build/Products/Debug-iphoneos/iAlumni.app/iAlumni' -- No such file or directory (/Users/Adam/Library/Developer/Xcode/DerivedData/iAlumni-evlhawkehmiqrzacwjvtozfzhkcx/Build/Products/Debug-iphoneos/iAlumni.app/iAlumni)


★  页面偏转

aVC -> bVC

下面两种方式,返回时aVC不会调用init.

aVC:[self.navigationController pushViewController:groupListVC animated:NO];

bVC:back button


aVC:[self presentModalViewController:helpVC animated:NO];

bVC:[self dismissModalViewControllerAnimated:YES];


★  等比例缩放

UIImageView *showImageView = [[[UIImageView alloc] initWithFrame:mImgFrame] autorelease];

showImageView.contentMode = UIViewContentModeScaleAspectFit;


★  安装新版本闪退

通过浏览器Safari一次更新ok,二次下载企业级应用,Crash log:

Apr 10 10:23:47 unknown SpringBoard[28] : The 'iAlumni' bundle at /private/var/mobile/Applications/DCEF5386-2594-4118-A906-3525671E230B/iAlumni.app does not have an executable path. Please check the bundle's Info.plist file.

企业版本更新,在程序里面进行,而非通过;页面更新。


★  安装新版本闪退

-[CALayer retain]: message sent to deallocated instance 0xcfbda30

查找下面关键词,看看是否存在二次释放。

autorelease

release

RELEASE_OBJ


★  Xcode symbol not found

工程的索引文件损坏,删掉下面目录里面的文件

/Users/Adam/Library/Developer/Xcode/DerivedData


 拒绝父类颜色 

self.view.backgroundColor = [UIColor clearColor];


 UIButton丰富展现 

    _authorImageBackgroundView = [[UIView alloc] initWithFrame:CGRectMake(MARGIN * 2, 

                                                                          MARGIN * 2, 

                                                                          POSTLIST_PHOTO_WIDTH, 

                                                                          POSTLIST_PHOTO_HEIGHT)];

    _authorImageBackgroundView.backgroundColor = [UIColor clearColor];

    UIBezierPath *shadowPath = [UIBezierPath bezierPath];

    

    [shadowPath moveToPoint:CGPointMake(2, 2)];

    [shadowPath addLineToPoint:CGPointMake(POSTLIST_PHOTO_WIDTH + 1, 2)];

    [shadowPath addLineToPoint:CGPointMake(POSTLIST_PHOTO_WIDTH + 1, POSTLIST_PHOTO_HEIGHT + 1)];

    [shadowPath addLineToPoint:CGPointMake(2, POSTLIST_PHOTO_HEIGHT + 1)];

    [shadowPath addLineToPoint:CGPointMake(2, 2)];


    [shadowPath addArcWithCenter:CGPointMake(POSTLIST_PHOTO_WIDTH/2 + 2, POSTLIST_PHOTO_HEIGHT/2 + 2)

                          radius:PHOTO_SIDE_LENGTH/2 

                      startAngle:2 * M_PI 

                        endAngle:0 

                       clockwise:true];

    _authorImageBackgroundView.layer.shadowPath = shadowPath.CGPath;

    _authorImageBackgroundView.layer.shadowColor = [UIColor darkGrayColor].CGColor;

    _authorImageBackgroundView.layer.shadowOpacity = 0.9f;

    _authorImageBackgroundView.layer.shadowOffset = CGSizeMake(0, 0);

    _authorImageBackgroundView.layer.masksToBounds = NO;

    [self.contentView addSubview:_authorImageBackgroundView];


    _authorImageButton = [UIButton buttonWithType:UIButtonTypeCustom];

    _authorImageButton.frame = CGRectMake(0, 0, POSTLIST_PHOTO_WIDTH, POSTLIST_PHOTO_HEIGHT);

    _authorImageButton.layer.cornerRadius = 6.0f;

    _authorImageButton.layer.masksToBounds = YES;

    _authorImageButton.layer.borderWidth = 2.0f;

    _authorImageButton.layer.borderColor = [UIColor whiteColor].CGColor;

    _authorImageButton.showsTouchWhenHighlighted = YES;

    [_authorImageButton addTarget:self action:@selector(openProfile:) forControlEvents:UIControlEventTouchUpInside];

    [_authorImageBackgroundView addSubview:_authorImageButton];


 [self performSelector:@selector(doNext) withObject:nil afterDelay:0.01f]; 


☆TASK:
BaseUITableViewCell 整合 ECTextBoardCell



self.view.frame.size.width
LIST_WIDTH


★ /* Calculate screen size */
CGRect screenFrame = [[UIScreen mainScreen] applicationFrame];


★ 自定义UITableViewCell怎样在子控件触发时得到indexPath
NSIndexPath *indexPath = [_tableView indexPathForCell:(UITableViewCell *)[sender superview]];
UITableViewCell *cell = [_tableView cellForRowAtIndexPath:indexPath];
[as showFromRect:cell.bounds inView:cell animated:TRUE];


★ presentModalViewController
UserDetailViewController *userProfileVC = [[UserDetailViewController alloc] initWithPersonIdByNet:CLUB_USER_TY needAddContact:YES personId:userId personType:userType];
UINavigationController *navigationView = [[UINavigationController alloc] initWithRootViewController:userProfileVC];
navigationView.navigationBar.tintColor = TITLESTYLE_COLOR;
userProfileVC.MOC = _MOC;
userProfileVC.title = LocaleStringForKey(NSUserProfileTitle, nil);
[self presentModalViewController:navigationView animated:YES];
RELEASE_OBJ(userProfileVC);
RELEASE_OBJ(navigationView);


mNC.modalPresentationStyle = UIModalPresentationCurrentContext;
mNC.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;

你可能感兴趣的:(ios)