小编Fer*_*ndo的帖子

UITextView统一了行背景,但行高错误

我有一个UITextView,用户可以在其中创建笔记并保存到plist文件中.我希望能够像普通笔记本一样显示线条.我遇到的问题是文本无法正确对齐.

下图很好地解释了问题.

我的打印屏幕很好地解释了这个问题

这是我用来创建像Notes.app这样的行的背景 在此输入图像描述

这是我为我创建背景的代码UITextView:

textView.font            = [UIFont fontWithName:@"MarkerFelt-Thin" size:19.0]; 
textView.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed: @"Notes.png"]];
Run Code Online (Sandbox Code Playgroud)

我知道该UIFont.lineHeight属性仅适用于> iOS 4.x.

所以我想知道我的问题是否有另一种解决方案?

iphone objective-c uitextview

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

在MKMapView中加载可见区域的注释

我有大约400个MKAnnotationView同时加载到MKMapView中.

我知道这不是什么好事,它有点慢,我想以"正确"的方式做到这一点.

我用中心坐标缩放地图:

MKCoordinateSpan span;
span.latitudeDelta = 0.8;
span.longitudeDelta = 0.8;

MKCoordinateRegion region;
region.span = span;

region.center = self.selectedCounty.coordinate;

[mapView setRegion:region animated:TRUE]; 
Run Code Online (Sandbox Code Playgroud)

我只希望加载注释,可能是在该地区可见.

我有一个自定义MKAnnotation,简称为"注释",带有CLLocationCoordinate2D-和title-property.

我只是想在MKMapView上加载"可见区域"的注释,因此并非所有注释都同时加载.当MKMapView上的"可见区域"发生变化时,我当然希望为该区域加载注释.

我知道MKMapView有一个委托方法,它在区域变化时运行.

但是,我怎么知道我应该为该区域加载哪些注释?

objective-c iphone-sdk-3.0

14
推荐指数
3
解决办法
8418
查看次数

在Xcode中为iPad指定图像,如iPhone 2的@ 2x

我已将当前目标升级到iPad并制作了一个通用应用程序,如果有这个问题的答案,调整我的iphone应用程序到ipad的时间会大大减少.

到这个时候,每个人都知道,如果你有一个名为" football.png " 的图像,并希望支持Retina Display,你应该将图像的大小加倍并称之为" football@2x.png ".

我的问题是,如果有像@football@iPad_which_is_another_size.png*这样的iPad吗?

如果没有办法做到这一点,我是否必须将每个图像连接到IBOutlet并以编程方式设置框架?

xcode objective-c ipad ios

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

从iPhone打开谷歌地图并显示路线

我想知道如何从我的iphone应用程序打开Goog​​le地图,以便Google地图在您到达网页时显示路线?

今天我使用的代码显示坐标.

        NSString *latlong = [NSString stringWithString: @"59.33267,18.07361"];
        NSURL *url = [[[NSURL alloc] initWithString:[NSString stringWithFormat: @"http://maps.google.com/maps?ll=%@", [latlong stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] ]] autorelease];
        [[UIApplication sharedApplication] openURL:url];
Run Code Online (Sandbox Code Playgroud)

iphone

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

NSDateFormatter dateFromString

来自我的数据源的字符串格式如下:

2011-04-11 23:12:05

// dateString comes from my data source, and look like I've said like this.
dateString = @"2011-04-11 23:12:05";

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"MMMM"];

NSDate *date = [formatter dateFromString:dateString];
Run Code Online (Sandbox Code Playgroud)

当我在这样的线程之后搜索互联网时,答案一直是dateString格式错误.但我的dateString是正确的之一,对吧?

为什么日期返回nil?

objective-c nsdateformatter

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

Wordpress用户自定义字段(复选框)从任何地方检索和更新

我在Wordpress>用户>配置文件字段中创建了一个自定义字段(复选框).我的网站是新闻的全方位网站,因此它通过RSS收集来自20个不同来源的新闻,并在我的Wordpress网站中添加它们的帖子.这是我的自定义字段的样子:

在此输入图像描述

如果您只是我首页上的访问者,我会在首页上显示所有帖子.

如果您是登录用户; 那么你应该能够在我的网站的起始页面上选择和保存你想要阅读的20个来源.这可以在今天选择和保存,但仅限于BP用户设置页面:

从BP用户设置中选择并保存源

现在,"用户配置文件设置"页面的问题是:

a)我不希望在"配置文件>编辑"选项卡中显示该表单.我希望我的表单在我的起始页上(在新闻流程之上,当然是登录用户),也许在某个时间点在一个小部件中 - 无论如何 - 最重要的是,可以自由地在任何地方放置(和样式)表单.

b)表单包括我要删除的字段(名称和描述,即"来源"=字段名称)等.

上图中的用户已选择并保存,以便从我网站上的两个不同来源读取新闻.处理此问题的代码位于index.php的起始页上:

$sources = xprofile_get_field_data( 'sources', $current_user_id, $multi_format = 'array' );
query_posts(array('category__and'=>array($sources)));
Run Code Online (Sandbox Code Playgroud)

问题 有没有办法检索此表单并从登录用户的任何地方更新?我不想受限于仅在"配置文件设置"页面中具有该表单的想法.我希望用户必须在我网站的首页上方形成我的新闻流,因此用户会感觉"哦,如果我创建一个帐户,我可以自定义我的新闻流!" - 这应该从登录用户的任何地方完成.

php wordpress buddypress wordpress-plugin

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

在现有的iPhone/iPad应用程序上更改目标设备系列

我刚刚上传了一个新的应用程序.这是版本1.0,支持的目标设备系列是:iPhone/iPad.

然后我上传了一个名为2.0的更新,这仍然是iPhone/iPad的目标.

之后我做了另一个小改动并上传了2.1版,这仍然是iPhone/iPad的目标.

现在问题:我现在正在尝试更换版本2.1但没有 iPad支持.新版本应该只支持iPhone.

我收到的错误消息如下:

"此捆绑包不支持此应用程序的先前捆绑包中支持的一个或多个设备.捆绑包必须继续支持以前支持的任何设备."

我试图将版本设置为2.2,但由于我无法创建或替换2.1版本,这是不可能的.

我从哪里开始?

iphone ipad ios4

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

UITableViewCells之间的透明度

我想在UITableViewCells之间保持透明.细胞之间的空间.

我用户自定义创建的单元格和设置背景我使用此代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CustomCell = @"CustomBookingCell";

    currentBooking = [arrayBookings objectAtIndex:indexPath.row];

    CustomBookingCell *cell = (CustomBookingCell *)[tableView dequeueReusableCellWithIdentifier:CustomCell];

    if (cell == nil) {

        UIViewController *c = [[UIViewController alloc] initWithNibName:@"CustomBookingCell" bundle:nil];
        cell = (CustomBookingCell *)c.view;
        [ c release ];
    }



    bookingImage = [[UIImageView alloc] initWithImage:
                     [UIImage imageNamed:currentBooking.imageSource]];

    [cell.imageForBooking addSubview:bookingImage];
    cell.selectionStyle = UITableViewCellSelectionStyleGray;
    cell.contentView.backgroundColor = [UIColor clearColor];


    UIView* backgroundView = [[UIView alloc] initWithFrame:CGRectZero];
    UIImage* bgImage = [UIImage imageNamed:@"Background_300_82.png"];
    UIColor *bgColor = [[UIColor alloc] initWithPatternImage: bgImage];

    backgroundView.backgroundColor …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch uikit

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

当隐藏UITableViewCell时,accessoryTypeCheckmark消失

我正在创建一个跟踪截止日期的功能.在截止日期表视图中选择一行时,我将accessoryType更改为Checkmark.这与以下代码完美配合:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{
    Cell *selectedCell = (Cell *)[tableView cellForRowAtIndexPath: indexPath];

    if (selectedCell.accessoryType == UITableViewCellAccessoryNone) {
        [Deadline setDone: TRUE onIndex:indexPath.row];
        selectedCell.accessoryType = UITableViewCellAccessoryCheckmark;

    } else {
        [Deadline setDone: FALSE onIndex:indexPath.row];
        selectedCell.accessoryType = UITableViewCellAccessoryNone;
    }

    [tableView deselectRowAtIndexPath:indexPath animated: YES];
}
Run Code Online (Sandbox Code Playgroud)

当您选择一个表格单元格并滚动它以使其消失时,会出现此问题,当再次出现时,accessoryType为None.

我在cellForRowAtIndexPath中决定accessoryType的代码是:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
    static NSString *CellIdentifier = @"CellIdentifier";

    Deadline *d = [self.arrDeadlines objectAtIndex:indexPath.row];

    Cell *currCell = (Cell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (currCell == nil) 
    {
        UIViewController *c = [[UIViewController alloc] initWithNibName:@"Cell" bundle:nil];
        currCell …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uitableview

0
推荐指数
1
解决办法
277
查看次数