小编Mus*_*afa的帖子

iPhone编程:将Alpha应用于父级但不应用于子视图

是否可以为父视图设置Alpha为.75或.50(透明),但子视图/控件是不透明的(Alpha通道1.0 - 完全可见).

每当我将主要UIView的Alpha设置为透明时,所有子视图/控件也显示为透明.有没有解决方法?

iphone alpha uiview

29
推荐指数
2
解决办法
1万
查看次数

在UITableView中设置滚动位置

我有一个类似于iPhone的Contact应用程序工作的应用程序.当我们添加新的联系人时,用户将被定向到包含联系信息的仅查看屏幕.如果我们从导航栏中选择"所有联系人",则用户将导航到最近添加的联系人所在的所有联系人列表.

我们可以使用以下方法将视图移动到特定行:

    [itemsTableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionBottom];
Run Code Online (Sandbox Code Playgroud)

......但它不起作用.我在打电话后正确地说这个:

    [tableView reloadData];
Run Code Online (Sandbox Code Playgroud)

我想我不打算selectRowAtIndexPath:animated:scrollPosition在这里打电话给方法.但如果不在这里,那么在哪里?

是否有任何委托方法在以下方法后调用?

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c uitableview ios

27
推荐指数
2
解决办法
9万
查看次数

Objective-C:如何将字符串格式化为$ Price

他们是一种内置的格式化字符串的方式为$ price,例如12345.45转换为$12,345.45

formatting currency objective-c

27
推荐指数
2
解决办法
2万
查看次数

使用CoreData的Grand Central Dispatch(GCD)

我在我的申请中使用Grand Central Dispatch(GCD)来做一些繁重的工作.该应用程序使用Core-Data进行数据存储.这是我的场景(以及相关问题):

dispatch_queue_t main_queue = dispatch_get_main_queue();
dispatch_queue_t request_queue = dispatch_queue_create("com.app.request", NULL);

dispatch_async(request_queue, ^{
    MyNSManagedObject *mObject = [self.fetchedResultsController objectAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];

    // … 
    // <heavy lifting>
    // … 

    // … 
    // <update mObject>
    // … 

    [self saveManagedObjectContext];
});     
Run Code Online (Sandbox Code Playgroud)

因此[self saveManagedObjectContext],fetchResultsController委托方法会自动调用.因此,UI更新逻辑启动.

现在的问题是,我需要用main_queue-saveManagedObjectContext?我应该在我执行的所有操作NSManagedObjectmain_queue?某些更新操作NSManagedObject可能需要2-3秒.请指教.

iphone core-data grand-central-dispatch objective-c-blocks

22
推荐指数
2
解决办法
2万
查看次数

格式化数字为百分比

我不明白NSNumberFormatterPercentStyle是如何工作的!

例:

NSNumber *number = [NSNumber numberWithFloat:90.5];
NSNumberFormatter *percentageFormatter = [[[NSNumberFormatter alloc] init] autorelease];
[percentageFormatter setNumberStyle:NSNumberFormatterPercentStyle];

NSString *strNumber = [percentageFormatter stringFromNumber:numbericString];
NSLog (strNumber);  // Output: 9,050%
Run Code Online (Sandbox Code Playgroud)

我只想表现出"90.5%"(尊重NSLocal).什么是NSNumberFormatterPercentStyle使用90.5,为什么?而且,我怎样才能得到我想要的结果!?

iphone percentage nsnumber nsnumberformatter ios

21
推荐指数
2
解决办法
6592
查看次数

Core-Data将保存:方法

我有一个属性modificationDate,我Entity A.想在NSManagedObject保存时设置它的值.但是,如果我尝试在NSManagedObject willSave:方法中这样做,我会收到一个错误:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Failed to process pending changes before save.  The context is still dirty after 100 attempts.  Typically this recursive dirtying is caused by a bad validation method, -willSave, or notification handler.' ***
Run Code Online (Sandbox Code Playgroud)

所以,我想知道,设定价值的最佳方法是modificationDate什么?

core-data objective-c nsmanagedobject

21
推荐指数
4
解决办法
1万
查看次数

Interface Builder是否使用-init方法初始化视图控制器?

我使用界面构建器设置了标签栏控制器,每个标签栏项链接到一个视图控制器(4个标签,4个视图控制器).我想知道Interface Builder是否使用-init方法来初始化视图控制器,因为显然这个方法没有被调用:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil;
Run Code Online (Sandbox Code Playgroud)

......我想做一些初始化.我无法添加它,-viewDidLoad因为它在内存警告的情况下被召回.任何的想法?

cocoa-touch interface-builder

20
推荐指数
3
解决办法
1万
查看次数

在iPhone模拟器上运行Apple Store应用程序?

我可以在iPhone模拟器上从Apple Store运行下载应用程序吗?

iphone ios-simulator

19
推荐指数
1
解决办法
8619
查看次数

重命名xcdatamodel文件

重命名.xcdatamodel文件需要做什么.重命名.xcdatamodel文件名,以及更改...

NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"newfilename" withExtension:@"momd"];
__managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];    
return __managedObjectModel;
Run Code Online (Sandbox Code Playgroud)

NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"newfilename.sqlite"];
Run Code Online (Sandbox Code Playgroud)

不起作用!我收到以下错误:

2011-04-11 17:19:54.164 ProjectName[5826:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Cannot create an NSPersistentStoreCoordinator with a nil model'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x00fa15a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x010f5313 objc_exception_throw + 44
    2   CoreData                            0x00013853 -[NSPersistentStoreCoordinator initWithManagedObjectModel:] + 419
    3   ProjectName                         0x00003471 -[ProjectNameAppDelegate persistentStoreCoordinator] + 257
    4   ProjectName                         0x000031a4 -[ProjectNameAppDelegate …
Run Code Online (Sandbox Code Playgroud)

core-data ios xcode4

19
推荐指数
3
解决办法
1万
查看次数

(iphone)强制scrollViewDidEndDecelerating在以编程方式滚动视图后调用?

我用滚动动画滚动 scrollRectToVisible:animated:

但是scrollViewDidEndDecelerating没有被召唤.

有没有办法强制调用函数?

iphone animation uiscrollview

19
推荐指数
3
解决办法
9267
查看次数