2013-09-20 4 views
2

Мы скомпилировали и развернули приложение в среде iOS 6. Но теперь приложение становится аварийным в iOS 7 при появлении предупреждения. Приложение просто получает авария в [alertView show];Аварии в UIAlertView в iOS7

Но, то же приложение работает идеально в прошивке 6.

кодекса для показа предупреждения

-(void)displayAlertWithMessage:(NSString *)message withTitle:(NSString *)title andTag:(int)tag 
{ 
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title message:message delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
    [alertView show]; 
} 

и вызова, как этого

[self displayAlertWithMessage:@"Please enter valid username!" withTitle:nil andTag:1]; 

Здесь находится журнал авария.

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/developer/Library/Application Support/iPhone Simulator/7.0/Applications/A0BCB945-8E4A-4D06-BEE8-240FF45ECF78/MyProject.app> (loaded)' with name '_UIModalItemAppViewController'' 
*** First throw call stack: 
(
    0 CoreFoundation      0x003176f4 __exceptionPreprocess + 180 
    1 libobjc.A.dylib      0x027c88b6 objc_exception_throw + 44 
    2 CoreFoundation      0x003174cb +[NSException raise:format:] + 139 
    3 UIKit        0x015d1bec -[UINib instantiateWithOwner:options:] + 951 
    4 UIKit        0x01444f05 -[UIViewController _loadViewFromNibNamed:bundle:] + 280 
    5 UIKit        0x014456ad -[UIViewController loadView] + 302 
    6 UIKit        0x014459ae -[UIViewController loadViewIfRequired] + 78 
    7 UIKit        0x01445eb4 -[UIViewController view] + 35 
    8 UIKit        0x018dc9da -[_UIModalItemsCoordinator _presentingViewControllerForAlertCompatibilityCreateIfNeeded:] + 248 
    9 UIKit        0x018dc8dd -[_UIModalItemsCoordinator _presentingViewControllerForAlertCompatibility] + 41 
    10 UIKit        0x01812801 -[UIAlertView(Private) popupAlertAnimated:animationType:atOffset:] + 382 
    11 UIKit        0x01812c1d -[UIAlertView(Private) popupAlertAnimated:animationType:] + 56 
    12 UIKit        0x01817c17 -[UIAlertView showWithAnimationType:] + 48 
    13 UIKit        0x01817c45 -[UIAlertView show] + 41 
    14 MyProject      0x000330a8 -[LoginViewController displayAlertWithMessage:withTitle:andTag:] + 232 
    15 MyProject      0x00032e8b -[LoginViewController isValidContent] + 299 
    16 MyProject      0x00033136 -[LoginViewController showSetPinView] + 54 
    17 libobjc.A.dylib      0x027da874 -[NSObject performSelector:withObject:withObject:] + 77 
    18 UIKit        0x0133524c -[UIApplication sendAction:to:from:forEvent:] + 108 
    19 UIKit        0x013351d8 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61 
    20 UIKit        0x0142ba5d -[UIControl sendAction:to:forEvent:] + 66 
    21 UIKit        0x0142be20 -[UIControl _sendActionsForEvents:withEvent:] + 577 
    22 UIKit        0x0142b0cf -[UIControl touchesEnded:withEvent:] + 641 
    23 UIKit        0x0137221d -[UIWindow _sendTouchesForEvent:] + 852 
    24 UIKit        0x01372e84 -[UIWindow sendEvent:] + 1232 
    25 UIKit        0x01346b86 -[UIApplication sendEvent:] + 242 
    26 MyProject      0x000c2c75 -[Application sendEvent:] + 101 
    27 UIKit        0x0133135f _UIApplicationHandleEventQueue + 11421 
    28 CoreFoundation      0x002a096f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15 
    29 CoreFoundation      0x002a02fb __CFRunLoopDoSources0 + 235 
    30 CoreFoundation      0x002bd3ce __CFRunLoopRun + 910 
    31 CoreFoundation      0x002bcbf3 CFRunLoopRunSpecific + 467 
    32 CoreFoundation      0x002bca0b CFRunLoopRunInMode + 123 
    33 GraphicsServices     0x036f0a27 GSEventRunModal + 192 
    34 GraphicsServices     0x036f084e GSEventRun + 104 
    35 UIKit        0x01333f0b UIApplicationMain + 1225 
    36 MyProject      0x00006612 main + 178 
    37 MyProject      0x00006555 start + 53 
) 
libc++abi.dylib: terminating with uncaught exception of type NSException 

Заранее спасибо.

+0

Что такое код? Вы рассмотрели разницу в том, как это реализовано в iOS7? – Wain

+0

Обновлен вопрос с образцом кода, пожалуйста, проверьте .. –

+1

Установлен ли ваш Xcode/iOS 7? Исключение говорит о невозможности загрузки NIB. – Wain

ответ

2

По аварии войти он говорит мне «[UIViewController _loadViewFromNibNamed: расслоение: ] " невозможно загрузить файл nib.

Но в моем проекте я создал категорию для класса UIViewController и переопределил метод -(id)init. Upto ios6, показывая предупреждение, этот метод категории вообще не выполняется, но от ios7 и выше переопределяется init() метод UIViewController.

Итак, я установил эту проблему путем добавления метода другого проверки в UIViewController категории в Init() для проверки методы класса является UIAlertView или не, если это UIAlertView то просто называя [super init]; вместо того, чтобы делать другие мои вещи, касающиеся просматривать контроллеры.

Пример кода:

- (id)init 
    { 
      NSString *viewControllerName = [NSString stringWithFormat:@"%@",[self class]]; 
      if([viewControllerName isEqualToString:@"UIAlertView"]) 
      { 
      self = [super init]; 
      } 
      else 
      { 
      // my stuff 
      } 
      return self; 
    } 
-1

вы можете проверить его .. старайтесь избегать нуля ... вместо того, чтобы положить что-то ... например [self displayAlertWithMessage: @ "Пожалуйста, введите действительное имя пользователя!" withTitle: @ "Hello" andTag: 1]

и вам нужно освободить вид предупреждения поэтому в коде функции выхода записи ...

Смежные вопросы