小编pab*_*sso的帖子

UITableViewCell accessoryType设置,但accessoryView是零.如何设置accessoryView backgroundColor?

以下是我的单元格设置方式:

- (UITableViewCell *)tableView:(UITableView *)tableViewIn cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"subcategory";
    UITableViewCell *cell = [tableViewIn dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    cell.textLabel.text = [[subcategories objectAtIndex:indexPath.row] title];
    cell.textLabel.font = [UIFont boldSystemFontOfSize:16];
    cell.textLabel.font = [UIFont boldSystemFontOfSize:16];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.selectionStyle = UITableViewCellSelectionStyleGray;

    cell.contentView.backgroundColor = [UIColor clearColor];

    cell.textLabel.textColor = [UIColor whiteColor];
    cell.textLabel.highlightedTextColor = [UIColor whiteColor];

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

正如人们所看到的,我设置的背景contentView,而且工作得很好-但是当我尝试做同样的事情backgroundView或者accessoryView,什么都不会发生,因为backgroundViewaccessoryView这两个似乎是零.

当一个人设置accessoryType而不是accessoryView …

iphone cocoa-touch objective-c ios

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

UITableViewCell/UISegmentedControl边界问题

我正试图在设置应用程序中的wifi设置中获得一个UISegmentedControlUITableViewCell.我遇到的问题是我有双边框.我得到一个边框UISegmentedControl,一个用于UITableViewCell.

我猜我需要删除边框UITableViewCell.我怎么能这样做呢?

iphone objective-c uitableview uisegmentedcontrol uikit

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

NSOperation,观察者和线程错误

NSOperation和观察者有问题.

我有一个tabbarcontroller和一个splashController.我想加载启动画面并下载文件,下载文件后tabbarcontroller会显示在屏幕上.

问题是我有一个错误:

bool _WebTryThreadLock(bool),0x3d2fa90:试图从主线程或Web线程以外的线程获取Web锁.这可能是从辅助线程调用UIKit的结果.现在崩溃......

这是我的代码:

- (void)applicationDidFinishLaunching:(UIApplication *)application {

    queue = [[NSOperationQueue alloc] init];


    NSString *path = [NSString stringWithFormat:@"%@flux.xml",DOCPATH];
    //Le fichier existe dans le repertoire des documents
    if([[NSFileManager defaultManager] fileExistsAtPath:path])
        [window addSubview:tabBarController.view];
    else
    {
        splash = [[SplashController alloc] init];
        [window addSubview:splash.view];
    }

    DataLoadOperation *operation = [[DataLoadOperation alloc] initWithURL:[NSURL URLWithString:@"http://sly.33.free.fr/flux.xml"]];
    [self.queue addOperation:operation];
    [operation addObserver:self forKeyPath:@"isFinished" options:NSKeyValueObservingOptionNew context:nil];


}

-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
    [window addSubview:tabBarController.view];
    [window makeKeyAndVisible];
    NSLog(@"fini");

} …
Run Code Online (Sandbox Code Playgroud)

iphone sdk

6
推荐指数
1
解决办法
6651
查看次数

CALayer位置包含NaN:[nan -0.5]

我在运行应用程序时在控制台中看到此日志:

CALayer position contains NaN: [nan -0.5]
Run Code Online (Sandbox Code Playgroud)

该应用程序包含一个UITaBar第一个选项卡是a UINavigationController.在NavController我发布的AddressBookPicker.在AddressBookPicker我只选择显示电话号码.

当我选择只有电子邮件地址的联系人时,就是当我看到这个日志时.

我没有看到任何崩溃或任何问题,只是打印到控制台上的日志.想要确保这不是一个在发布后崩溃的隐藏问题.

下面是相关代码和堆栈跟踪的片段.不确定要粘贴的代码的其他部分,请告诉我是否有任何可以发布的内容可能有所帮助.

任何帮助/输入赞赏.

谢谢!

ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];

NSArray *displayedItems = [NSArray arrayWithObjects: [NSNumber numberWithInt:kABPersonPhoneProperty]), nil];

picker.displayedProperties = displayedItems;

picker.peoplePickerDelegate = self;

[self presentModalViewController:picker animated:YES];
Run Code Online (Sandbox Code Playgroud)

堆栈跟踪

#0    0x00096377 in NSLog

#1    0x046b38c9 in CALayerSetPosition

#2    0x046b3846 in -[CALayer setPosition:]

#3    0x046b375f in -[CALayer setFrame:]

#4    0x002f510b in -[UIView(Geometry) setFrame:]

#5    0x003dbe6d in -[UILabel setFrame:]

#6    0x023ed095 in -[ABPersonTableViewDataSource …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ios4

6
推荐指数
1
解决办法
8146
查看次数

UITabBarController的'selectedViewController'更改时触发的事件?

当用户更改a的选定选项卡时UITabBarController,是否有一个事件被触发以指示此特定操作发生了?

我知道viewDidLoad如果UIViewController以前没有加载就可以被解雇,如果是这样的话,viewWillAppear可以调用它.但这些都不会告诉我视图已显示,因为选中了标签栏.

iphone uitabbarcontroller uiviewcontroller

6
推荐指数
1
解决办法
4859
查看次数

UINavigationController 在 UITabBarController 的 moreNavigationController 中不起作用

我正在处理UINavigationControllers我的应用程序,所有这些都由UITabBarController. 一切工作正常,直到我的控制器落入自动生成的“更多”选项卡。

我在简单的示例中重现了该问题。难道我做错了什么?我想不通。

感谢您的帮助。

#import <UIKit/UIKit.h>

@interface testAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate>
{
    UIWindow *窗口;
    UITabBarController *tabBarController;
}
@property(非原子,保留)IBOutlet UIWindow *window;
@property(非原子,保留)IBOutlet UITabBarController *tabBarController;
@结尾

@实现testAppDelegate
@synthesize窗口,tabBarController;

- (void)applicationDidFinishLaunching:(UIApplication *)application
{
    tabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil];

    UINavigationController *ctrl1 = [[[UINavigationController alloc] initWithNibName:nil bundle: nil] autorelease];
    ctrl1.tabBarItem = [[[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFeatured tag:1] autorelease];

    UINavigationController *ctrl2 = [[[UINavigationController alloc] initWithNibName:nil bundle: nil] autorelease];
    ctrl2.tabBarItem = [[[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:2] autorelease];

    UINavigationController *ctrl3 = [[[UINavigationController alloc] initWithNibName:nil bundle: …

iphone uitabbarcontroller uinavigationcontroller

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

iPad/iPhone - NSString drawInRect没有自动换行

我正在使用以下内容来渲染一些文本UIView.

- (void) drawRect:(CGRect)rect
{

    NSString* text = @"asdf asdf asdf asdf asdf asdf asdf";

    CGContextRef context = UIGraphicsGetCurrentContext();

    CGContextSetFillColorWithColor(context, [[UIColor clearColor] CGColor]);

    CGContextFillRect(context, rect);

    CGContextSetTextDrawingMode(context, kCGTextFillStrokeClip);

    CGContextSetFillColorWithColor(context, [[UIColor whiteColor] CGColor]);

    CGContextSetStrokeColorWithColor(context, [[UIColor blackColor] CGColor]);

    CGContextSetShouldSmoothFonts(context, YES);

    UIFont* font = [UIFont fontWithName:@"ArialRoundedMTBold" size:20.0f]; 

    CGSize textMaxSize = CGSizeMake(rect.size.width - 20.0f, rect.size.height);

    CGSize textSize = [text sizeWithFont:font constrainedToSize:textMaxSize lineBreakMode:UILineBreakModeWordWrap];

    CGRect textRect = CGRectMake(10.0f, 10.0f, textSize.width, textSize.height);

    [text drawInRect:textRect withFont:font];

    [text drawInRect:textRect withFont:font lineBreakMode:UILineBreakModeWordWrap]; 

    [text drawInRect:textRect withFont:font lineBreakMode:UILineBreakModeWordWrap alignment:UITextAlignmentCenter];
}
Run Code Online (Sandbox Code Playgroud)

没有 …

iphone nsstring ipad ios4

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

Interface Builder:根据目标选择媒体

在 Xcode 中,我使用目标来发布多个应用程序版本,这些版本共享一些基本代码并且往往具有不同的图形。

IE。假装我有目标JOHN和目标DOE。我可以将准确命名的不同图像添加example.png到捆绑包中,并分别针对每个图像。这样代码不需要任何更改。

UIImageView *image = [UIImageView alloc] initWithImage:[UIImage imageNamed:@"example.png"]];
Run Code Online (Sandbox Code Playgroud)

相反,如果我为每个不同版本的图像命名,我最终会得到类似的结果:

NSString *imageName;

#ifdef JOHN
imageName = @"johnExample.png";
#else
imageName = @"doeExample.png";
#endif
UIImageView *image = [UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]];
Run Code Online (Sandbox Code Playgroud)

拥有多个版本和许多图像很快就会变得混乱,并且拥有一个包含常量的巨大文件在我看来有点过分了,所以我最终选择了第一个选择。

问题是:

在处理 nibs 文件时,Interface Builder 似乎只是随机加载example.png。因此,如果我正在处理目标,那么 IB 刚刚决定从目标JOHN加载就会很烦人。example.pngDOE

Interface Builder 有什么方法可以根据目标加载媒体吗?

iphone objective-c interface-builder ios

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

在iPhone上同时播放两个视频

我想同时在iPhone上播放两个视频.

在iphone中有两种播放视频的方式,一种是使用AVQueuePlayer.但在这个控制器中我不知道如何完成视频播放以及如何重新启动视频.

另一种方式是MPMoviePlayerController.但在这个控制器中,我不知道如何在特定时间寻找视频,也无法同时播放两个视频,因为AVQueuePlayer它能够播放.

作为我AVQueuePlayer用于播放视频的解决方案,但任何人都可以帮助我重新启动视频并获取检测视频终点的方法.或知道任何其他api这样的

提前致谢.

iphone objective-c mpmoviewcontroller

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

在graphviz上设置节点方向

假设此代码使用neato:

graph sample {
  layout=neato
  overlap=false
  splines=true
  tailclip=false
  headclip=false
  A -- I
  A -- J
  A -- B
  A -- H
  A -- E
  A -- K
  B -- D
  B -- C
  B -- L
  C -- M
  C -- N
  C -- O
  D -- P
  D -- Q
  E -- R
  F -- A
  G -- F
  H -- J
}
Run Code Online (Sandbox Code Playgroud)

这给了我们这个图:

neato图

我需要的是放置一个节点X,始终固定在父节点以南的位置.即如果我把另一种关系A -- X,X应该总是放在南方A.而且我并不关心其他所有事情的结局.

我已经查看了pos属性,但它似乎不是解决方案,因为X …

dot graphviz neato

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