저는 IOS 프로그래밍에 익숙하지 않지만 하루 이상 지속되어 해결책을 찾을 수없는 문제가 있습니다. 설치 후 첫 번째 실행시 일부 콘텐츠를 다운로드해야하는 앱이 있습니다. 다운로드가 완료되면 RootView 컨트롤러 인 View가 뷰의 데이터를 새로 고치지 않습니다. 올바르게 채워지지만 다른 뷰는 탐색 할 수 있지만이 뷰는 그렇지 않습니다. 내가 응용 프로그램을 닫고 다시 열면 데이터가 나타납니다. 그래서보기를 완전히 다시로드하거나 응용 프로그램을 다시 시작하는 방법이 필요합니다.RootView 컨트롤러를 다시로드하거나 응용 프로그램을 다시 시작하십시오.
#import <UIKit/UIKit.h>
#import <CoreData/CoreData.h>
@interface RootViewController : UIViewController <NSFetchedResultsControllerDelegate>{
}
@property (nonatomic, retain) IBOutlet UIImageView *bannerImageView;
@property (nonatomic, retain) NSFetchedResultsController *fetchedResultsController;
@property (nonatomic, retain) NSManagedObjectContext *managedObjectContext;
-(void)populateBannerImages;
-(void)getimage;
는 여기에 내가 아래 코드 샘플 응용 프로그램 위임의 다운로드 기능에 대한 대화 상자를 실행 내하는 .m 파일
@implementation RootViewController
@end
- (void)viewDidLoad
{
[super viewDidLoad];
[email protected]"MyTitle";
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return [[self.fetchedResultsController sections] count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection: (NSInteger)section
{
id <NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:section];
return [sectionInfo numberOfObjects];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
[self configureCell:cell atIndexPath:indexPath];
return cell;
}
입니다. 문제는 appDidFinishLAunching에서 UIAlert를 호출하고이 시점에서 rootViewController가 이미로드되었다는 것을 알지만이 작업을 수행하는 데 더 좋은 방법은 아닌 것 같습니다. 그 통지에 등록 모든 뷰 컨트롤러와 NSNotificationCenter를 통해 NSNotification를 파견 :
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
BOOL hasRunBefore=[[NSUserDefaults standardUserDefaults] boolForKey:@"FirstRun"];
if (hasRunBefore) {
}else if(!hasRunBefore){
UIAlertView *firstRunAlert =[[UIAlertView alloc]initWithTitle:@"Welcome" message:@"" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"DownLoad", nil];
[firstRunAlert show];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"FirstRun"];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
NSString *buttontitle = [alertView buttonTitleAtIndex:buttonIndex];
if ([buttontitle isEqualToString:@"DownLoad"]) {
/download stuff here
}
}
어떤 건설적인 아이디어 나 것 도움을 크게
저장 용량에 핵심 데이터를 사용하는 것 같습니다.핵심 데이터는 강력한 프레임 워크이지만이를 사용하려면 고급 iOS 개발자 여야합니다 (리로드 알림을 구현하는 방법조차 모릅니다) –
예 마틴 (Martin) 저는 의견에 오만함과 냉소의 만지기를 고맙게 생각합니다. 하지만 이미 푸시 알림을 사용하고 있었고 작동하지 않았습니다. 핵심 데이터는 IOS에만 해당되는 것이 아니므로 고급 IOS 개발자가 아니기 때문에 필수적으로 사용해야합니다. ControllerDidChangeContent에서 reloadData가 누락되었습니다. 내가 괜찮다고 덧붙인 후에도 여전히 실질적인 질문에 대답하기 위해 당신의 매력적인 도움이되는 태도 – user1005382