すべてのビュー コントローラー (4 ビュー) に広告バナー (内部アクティブ) を含むアプリがあり、アプリが実行されている 2、3、4 分後にこのエラーが発生し続けます。
'NSRangeException', reason: '*** -[__NSCFString substringToIndex:]: Range or index out of bounds'
アプリがクラッシュし、その解決策が見つかりませんが、広告バナー コードにコメントを付けると、AD バナーの問題が原因であることがわかります。すべてがうまく機能します。新しいリクエストがバナーに読み込まれているときに発生すると想定できます。
これは、AD バナーに使用しているコードです。
.h ファイル:
@property (nonatomic, retain) UIView *adBanner;
.mファイル:
必要なものを合成してインポートし、その後:
- (void)viewWillAppear:(BOOL)animated
{
CGRect frame = CGRectMake(0, 430, 320, 50);
self.adBanner = [[UIView alloc] initWithFrame:frame];
[self.view addSubview:self.adBanner];
// Display ad
if (![InneractiveAd DisplayAd:@"iOS_Test" withType:IaAdType_Banner withRoot:adBanner withReload:60 withParams:optionalParams])
{
adBanner.hidden = YES;
}
}
これは私の AppDelegate です (理由はわかりませんが、それと何か関係があるのでしょうか?):
.h ファイル:
#import <UIKit/UIKit.h>
@class RootViewController;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (nonatomic, strong) RootViewController *rootViewController;
@end
.m ファイル:
#import "AppDelegate.h"
#import "RootViewController.h"
@implementation AppDelegate
@synthesize window = _window;
@synthesize rootViewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.rootViewController = [[RootViewController alloc] initWithNibName:nil bundle:NULL];
[self.window addSubview:self.rootViewController.view];
[self.window makeKeyAndVisible];
return YES;
}
それが何であるか、そしてそれが NSCFString にどのように関連しているかは本当にわかりません:\
ありがとう。