小编Reu*_*ven的帖子

导航栏中的iPhone标题和副标题

在我的应用程序中,我希望导航栏显示标题和副标题.

在这种程度上,我将以下代码添加到我的视图控制器:

// Replace titleView
CGRect headerTitleSubtitleFrame = CGRectMake(0, 0, 200, 44);    
UIView* _headerTitleSubtitleView = [[[UILabel alloc] initWithFrame:headerTitleSubtitleFrame] autorelease];
_headerTitleSubtitleView.backgroundColor = [UIColor clearColor];
_headerTitleSubtitleView.autoresizesSubviews = YES;

CGRect titleFrame = CGRectMake(0, 2, 200, 24);  
UILabel *titleView = [[[UILabel alloc] initWithFrame:titleFrame] autorelease];
titleView.backgroundColor = [UIColor clearColor];
titleView.font = [UIFont boldSystemFontOfSize:20];
titleView.textAlignment = UITextAlignmentCenter;
titleView.textColor = [UIColor whiteColor];
titleView.shadowColor = [UIColor darkGrayColor];
titleView.shadowOffset = CGSizeMake(0, -1);
titleView.text = @"";
titleView.adjustsFontSizeToFitWidth = YES;
[_headerTitleSubtitleView addSubview:titleView];

CGRect subtitleFrame = CGRectMake(0, 24, 200, 44-24);   
UILabel *subtitleView …
Run Code Online (Sandbox Code Playgroud)

iphone title subtitle uinavigationcontroller uinavigationitem

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

在XCode 4.2中使用动态自定义UITableViewCell,使用Storyboards和UISeachDisplayController

我已经使用Xcode 4.2来创建基于故事板的iOS应用程序.我的一个屏幕包含一个UITableViewController,使用动态自定义单元格.

到现在为止还挺好.

现在,我想添加一个UISearchDisplayController以允许过滤我的列表.

出于某种原因,UISearchDisplayController将不会显示我的自定义单元格,我找不到强制它的方法...

这是我的cellForRowAtIndexPath方法的样子:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"QueueListCell";
    QueueListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[QueueListTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
                                             reuseIdentifier:CellIdentifier];
    }
    assert(cell);

    if ([tableView isEqual:self.searchDisplayController.searchResultsTableView]) {
        indexPath = [_indexPathsForSearchResults objectAtIndex:indexPath.row];
    }

    // Set up the cell...
    NSDictionary* itemDict = [_ListItems objectAtIndex:indexPath.row];

    cell.labelQueueName.text = [itemDict objectForKey:kQueueName];
    cell.labelQueueNumItems.text = [[itemDict objectForKey:kQueueNumItems] stringValue];

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

有关如何使这个工作的任何想法?我的意思是,我的UISearchDisplayController表显示正确的结果数量(我知道,因为我可以点击它们,我添加了一个NSLog让我知道我点击了什么......)

这是我的表格视图 这是我的表格视图

这就是搜索显示表的样子...... 这就是搜索显示表的样子......

我的问题/问题是如何使UISearchDisplayController表视图显示我的自定义单元格?

任何帮助赞赏...

鲁文

iphone uitableview ios xcode-storyboard

14
推荐指数
1
解决办法
6815
查看次数

iPhone:检测UIAlert/UIActionSheet是否打开

在我的iOS应用程序中,我有一个计时器启动,当它启动时,我需要能够检测是否有一个Alert(UIAlertView)或一个Action Sheet(UIActionSheet)打开.

一种方法是修改显示警报/操作表的代码 - 但不幸的是,这不是我的选择.

所以,问题是 - 有没有办法知道/检测警报或行动表是否已被打开?

是否有任何通知在打开时发送,或者任何遍历视图层次结构以检测它?

谢谢

iphone uialertview uiactionsheet

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

UIPopoverController中的iPad UIImagePicker仅选择已保存的图像(不是来自相册)?

在我的iPad应用程序中,我让用户使用以下代码选择图像:

UIImagePickerController* picker = [[UIImagePickerController alloc] init]; 
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
picker.delegate = self; 

UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker];
self.popoverController = popover;          
popoverController.delegate = self;
[popoverController presentPopoverFromRect:self.view.frame
                                   inView:self.view
                 permittedArrowDirections:UIPopoverArrowDirectionAny
                                 animated:YES];
[picker release];
Run Code Online (Sandbox Code Playgroud)

(我已经将类设置为UIPopoverControllerDelegate和UIImagePickerControllerDelegate,并且我为两个委托设置了回调.)

现在,奇怪的是,如果我从"已保存的照片"相册中选择一个图像,我的"imagePickerController:didFinishPickingImage"回调方法被调用,我得到一个图像,一切都很好.

但是,如果我从任何其他专辑中选择一个图像,我的"imagePickerControllerDidCancel"回调会被调用 - 而且我没有得到图像.

任何的想法?我在网上搜索高低......

谢谢,Reuven


情节加厚......

添加时:
allowsEditing = YES;

我仍然可以从已保存的照片相册中选择(和裁剪/缩放)图像 - 但是当尝试使用其他相册中的图像时,iPad会因调试器崩溃而显示:

2010-06-03 08:16:06.759 uPrintMobile [98412:207] *由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:'* - [NSCFDictionary setObject:forKey:]:尝试插入nil值(键:UIImagePickerControllerOriginalImage) "

仍然没有线索......

uiimagepickercontroller ipad uipopovercontroller

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

iOS(iPad)在UISplitViewController中拖放

我正在使用UISplitViewController(基于Xcode模板项目)进行D&D,从MasterViewController到DetailViewController.

基本上,我正在做的是创建一个UILongPressGestureRecognizer并将其放在MasterViewController的self.tableview属性上.

下面是我的手势识别器.

- (void)gestureHandler:(UIGestureRecognizer*)gesture
{
    CGPoint location;
    NSIndexPath* indexPath = [self.tableView indexPathForRowAtPoint:[gesture locationInView:self.tableView]];
    if (gesture.state == UIGestureRecognizerStateBegan) {
        // Create draggable view
        NSString* imageCanvasName = [self imageNameByIndexPath:indexPath isDetail:YES];
        UIImage* imageCanvas = [UIImage imageNamed:imageCanvasName];
        _draggedView = [[UIImageView alloc] initWithImage:imageCanvas];

        // Create drag-feedback window, add the drag-view and make the drag-window visible
        CGRect windowFrame = self.view.window.frame;
        _dragFeedbackWindow = [[UIWindow alloc] initWithFrame:windowFrame];
        location = [gesture locationInView:gesture.view.window];
        [_draggedView setCenter:location];
        [_dragFeedbackWindow addSubview:_draggedView];
        [_dragFeedbackWindow setHidden:NO];     
    }
    else if (gesture.state == UIGestureRecognizerStateChanged) {
        // Update drag-view …
Run Code Online (Sandbox Code Playgroud)

ipad uisplitviewcontroller ios

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

iPhone内存管理,一个新手问题

我已经在(Apple)示例代码中看到了两种分配内存的方式,并且我不确定我是否理解了差异和产生的行为.

// FAILS
NSMutableArray *anArray = [NSMutableArray array];
[anArray release];

// WORKS
NSMutableArray *anArray1 = [[NSMutableArray alloc] init];
[anArray release];
Run Code Online (Sandbox Code Playgroud)

通过"FAILS"我的意思是我遇到了崩溃/运行时警告等,并且并不总是在我发布后立即发布...

任何解释都赞赏.

谢谢

iphone memory-management

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