小编bru*_*h51的帖子

Malloc错误"无法分配区域"失败,错误代码为12.任何想法如何解决?

我收到此错误,不知道该怎么办:

AppName(3786,0xa0810540) malloc: *** mmap(size=16777216) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
Run Code Online (Sandbox Code Playgroud)

如果我设置断点到发生错误的那一行,我不知道我要专门搜索什么.在仪器中,我检查了分配,并且值增加到所有分配的14,5 GB.

有人可以帮我吗?
brush51

编辑1:
更多信息:
- 我在模拟器中尝试这个,而不是在iOS设备上.
- 这就是所有的输出(我得到这个错误的次数更多). - 此行发生错误:

NSManagedObjectContext *context = [self managedObjectContext];
NSFetchRequest *fetchREntitySetsCards = [[[NSFetchRequest alloc] init] autorelease];
//NSFetchRequest *fetchREntityRelCardsAnswersNotes = [[[NSFetchRequest alloc] init] autorelease];

NSEntityDescription *entitySetsCards = [NSEntityDescription entityForName:@"EntitySetsCards" inManagedObjectContext:context];
//NSEntityDescription *entityRelCardsAnswersNotes = [NSEntityDescription entityForName:@"EntityRelCardsAnswersNotes" inManagedObjectContext:context];
setEntity:entityCard];
[fetchREntitySetsCards setEntity:entitySetsCards];
//[fetchREntityRelCardsAnswersNotes setEntity:entityRelCardsAnswersNotes];

NSArray *fetchedObjSetsCards    = [context executeFetchRequest:fetchREntitySetsCards error:&error];
//The error is here--->
//NSArray …
Run Code Online (Sandbox Code Playgroud)

malloc memory-management allocation ios

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

如何从UICollectionViewCell访问UICollectionView中Cell的indexPath

我想动画UICollectionViewCell调用何时动作.
我已经做UICollectionViewCellInterface Builder,该UICollectionView还.现在我想indexPath在我的actionBtnAddToCard方法中得到正确的答案.

这就是我现在尝试的方式(ProduktViewCell.m中的方法):

- (IBAction)actionAddToCart:(id)sender {
    XLog(@"");

    // see this line
    NSIndexPath *indexPath = ??** how can i access the correct indexPath**??;
    SortimentViewController *svc = [[SortimentViewController alloc] initWithNibName:@"SortimentViewController_iPad" bundle:[NSBundle mainBundle]];
    [svc.collectionViewProdukte cellForItemAtIndexPath:indexPath];

    [svc collectionView:svc.collectionViewProdukte didSelectItemAtIndexPath:indexPath];
} 
Run Code Online (Sandbox Code Playgroud)

SortimentViewController是viewController,它继承了UICollectionView.
如何访问正确的indexPath?

更新1:编辑帖子以便更好地理解.

nsindexpath ibaction ios uicollectionview uicollectionviewcell

20
推荐指数
5
解决办法
6万
查看次数

如何在iOS上更改设备音量 - 而不是音乐音量

我想在iOS(iphone)上更改设备音量.

我知道我可以通过以下这些方式改变音乐库的音量:

//implement at first MediaPlayer framework
MPMusicPlayerController *musicPlayer = [MPMusicPlayerController iPodMusicPlayer];
musicPlayer.volume = 1;
Run Code Online (Sandbox Code Playgroud)

但这不是我的目标.
我想更改设备音量或者让我说一下铃声的音量.

我怎样才能做到这一点?只是更改DEVICE卷?

iphone volume device ios

15
推荐指数
4
解决办法
3万
查看次数

为什么UITextField在resignFirstResponder上设置动画?

从iOS 8开始,表单中的UITextField表现得非常奇怪.如果我单击另一个文本字段或按键盘上的Tab键,输入的文本将向上设置动画,然后快速重新显示.每次视图加载后都会发生这种情况,之后不时发生.

它看起来像这样:

动画

我的代码看起来像这样:

#pragma mark - <UITextFieldDelegate>

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    if (textField == self.passwordTextField) {
        [self loginButtonClicked:nil];
    } else if (textField == self.emailTextField) {
        [self.passwordTextField becomeFirstResponder];
    }

    return YES;
}
Run Code Online (Sandbox Code Playgroud)

编辑:

看起来这个问题是由我的键盘监听器引起的:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];


- (void)keyboardWillHide:(NSNotification *)sender
{
    self.loginBoxBottomLayoutConstraint.constant = 0;

    [self.view layoutIfNeeded];
}

- (void)keyboardWillShow:(NSNotification *)sender
{
    CGRect frame = [sender.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
    CGRect newFrame = [self.view convertRect:frame fromView:[[UIApplication sharedApplication] delegate].window];
    self.loginBoxBottomLayoutConstraint.constant = CGRectGetHeight(newFrame);

    [self.view layoutIfNeeded];
}
Run Code Online (Sandbox Code Playgroud)

animation objective-c uitextfield ios resignfirstresponder

15
推荐指数
1
解决办法
995
查看次数

如何理解和解决崩溃报告:SIGSEGV,SEGV_ACCERR

我有时会得到这个崩溃报告:

Name: SIGSEGV
Reason: SEGV_ACCERR
Stack Trace:

0 MyApp 0x00070456 0x1000 + 455766
1 MyApp 0x0007a34d 0x1000 + 496461
2 MyApp 0x0007a4f1 0x1000 + 496881
3 MyApp 0x000d31dd 0x1000 + 860637
4 MyApp 0x00067f0f 0x1000 + 421647
5 MyApp 0x0005ad69 0x1000 + 367977
6 MyApp 0x000081e3 0x1000 + 29155
7 MyApp 0x00008ae9 0x1000 + 31465
8 CoreFoundation 0x35a547e4 __invoking___ + 68
9 CoreFoundation 0x359af7b1 -[NSInvocation invoke] + 160
10 Foundation 0x3556268f -[NSInvocationOperation main] + 114
11 Foundation 0x354fb393 -[__NSOperationInternal start] …
Run Code Online (Sandbox Code Playgroud)

crash-reports segmentation-fault ios

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

Xcode可执行文件使用无效的权利签名

我会使用Xcode在我的手机中安装一个应用程序,但是没有安装,但后面出现错误信息.

  • 错误消息
    "可执行文件已使用无效的权利进行签名.应用程序的代码签名权利文件中指定的权利与您的配置文件中指定的权限不匹配.(0xE8008016)"


  • 调查事项
    1. 为什么安装应用程序时会出现错误消息?
    2. 你介意你能不能给我解决这个问题的方法?

iphone xcode ios

13
推荐指数
6
解决办法
3万
查看次数

更改UITable部分backgroundColor而不丢失部分标题

我已经更改了tableviews部分的backgroundColor/backgroundImage.
我使用普通的tableView.不用担心,使用此代码可以正常工作:

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView *sectionView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 728, 40)] autorelease];
sectionView.backgroundColor = [UIColor greenColor];

//For using an image use this:
//sectionView.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"whiteBackground.png"]];

return sectionView;
}  
Run Code Online (Sandbox Code Playgroud)

现在的问题是,章节标题已经消失.

我正在使用以下代码设置该部分的标题:

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {

if ([tableView isEqual:self.searchDisplayController.searchResultsTableView]){
    return @"";
} else {    
    id <NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:section];
    return [sectionInfo name];
}


}
Run Code Online (Sandbox Code Playgroud)

如果我不使用,我会得到章节标题

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section  
Run Code Online (Sandbox Code Playgroud)

需要你的帮助.
非常感谢.

编辑1:

感谢Mutix:

就我而言,答案是:

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { …
Run Code Online (Sandbox Code Playgroud)

title background-color sectionheader ios

7
推荐指数
2
解决办法
9123
查看次数

使用联系人框架创建新组,CNErrorDomain Code = 2

我尝试使用Contacts Framework创建和保存组.首先,用户授权应用程序进行联系人访问.提供了一个viewcontroller,并且+按钮用户显示带有textfield的alertview.

用户键入他想要的组名称,然后单击警报视图的按钮(保存).

这是保存新组的代码.组名称可用,但无论如何都无法保存此组:

CNContactStore *contactStore = [CNContactStore new];  

[contactStore requestAccessForEntityType:CNEntityTypeContacts completionHandler:^(BOOL granted, NSError *error){
if (granted) {

    CNMutableGroup *newGroup = [CNMutableGroup new];
    CNSaveRequest *saveRequest = [CNSaveRequest new];

    [newGroup setName:groupName];

    //when saving to container with identifier nil, we get this error:
    //Error Domain=CNErrorDomain Code=2 "(null)" UserInfo={CNInvalidRecords=(
    //"<CNMutableGroup: 0x10a059f20: identifier=2F4981B9-8A47-45A4-8841-1FA5A09584A4:ABGroup, name=gghh>"
    [saveRequest addGroup:newGroup toContainerWithIdentifier:nil];
    [contactStore executeSaveRequest:saveRequest error:&error];

    if (error){
        //error saving group
        //NSLog(@"error message: %@",error);
    } else {
        //if no errors, reload tableview
        dispatch_async(dispatch_get_main_queue(), ^{
            [self.tableView reloadData];
        });
    } …
Run Code Online (Sandbox Code Playgroud)

ios ios9 cncontact cncontactstore contacts-framework

7
推荐指数
1
解决办法
1803
查看次数

如何将Objective C代码放入Word(Office)并使用语法高亮显示

我正在编写有关应用程序的文档,并希望解释代码.我想将部分目标C代码从Xcode复制到Microsoft Word.我不知道如何将带有语法高亮的代码(也可能是行号?)放入Word中.

有没有人知道这个小问题的可用解决方案?

xcode ms-word objective-c ms-office

6
推荐指数
2
解决办法
5388
查看次数

如何理解这次崩溃?:SIGBUS BUS_ADRALN

多数民众赞成在堆栈跟踪,我不明白这个错误:

0   CoreFoundation  0x30f57648 ___CFBasicHashFindBucket_Linear_NoCollision + 92  
1   CoreFoundation  0x30f59688 __CFBasicHashAddValue + 692
2   CoreFoundation  0x30eaff9f CFDictionarySetValue + 74
3   UIKit   0x35721a0b -[UITouchesEvent _gestureRecognizersForWindow:] + 282
4   UIKit   0x357215d5 -[UIWindow _sendGesturesForEvent:] + 28
5   UIKit   0x357214ab -[UIWindow sendEvent:] + 66
6   UIKit   0x3570a313 -[UIApplication sendEvent:] + 298
7   UIKit   0x35709c53 _UIApplicationHandleEvent + 5090
8   GraphicsServices    0x31a11e77 PurpleEventCallback + 666
9   CoreFoundation  0x30f1ba97     __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
10  CoreFoundation  0x30f1d83f __CFRunLoopDoSource1 + 166
11  CoreFoundation  0x30f1e60d __CFRunLoopRun + 520
12  CoreFoundation  0x30eaeec3 …
Run Code Online (Sandbox Code Playgroud)

crash crash-reports sigbus ios

5
推荐指数
1
解决办法
3564
查看次数