小编Vir*_*ana的帖子

UIButton有图像和文字吗?

我有一个尺寸宽度为200,高度为270的按钮.我希望在同一个按钮上有文字和图像.不作为该文本的背景图像.而不是这个,我想在同一个按钮上显示高度为120的文本和高度为150的图像.怎么做?

iphone xcode uibutton ios

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

具有动态高度的UICollectionView不会在单元格之间获得相同的空间

我有类似的问题,这样的

我在运行时生成视图高度.这是我的代码

@interface CollectionViewController ()
{
    NSMutableArray *arrMain;
}
@property(nonatomic,strong) NSMutableArray *arrMain;
@end

@implementation CollectionViewController
@synthesize arrMain,


- (void)viewDidLoad
{
    [super viewDidLoad];

    [cView registerNib:[UINib nibWithNibName:@"CViewCell" bundle:nil] forCellWithReuseIdentifier:kCellID];

    CViewFlowLayout *fl = [[CViewFlowLayout alloc] init];
    self.cView.collectionViewLayout = fl;

    NSString *strJson = MY FUNCTION WHICH RETURNS JSON STRING;
    SBJSON *parser = [[SBJSON alloc] init];

    self.arrMain = [[NSMutableArray alloc] init];
    self.arrMain = [parser objectWithString:strJson error:nil];
    for (int i=0; i<[self.arrMain count]; i++) {
        NSDictionary *dic = [self.arrMain objectAtIndex:i];
        [self setTags:[[UIView alloc] init] selDictionary:dic];  // …
Run Code Online (Sandbox Code Playgroud)

objective-c ipad ios uicollectionview uicollectionviewcell

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

IOS应用程序 - 在单独的文件中定义协议

我在一个单独的文件(myProtocol.h)中定义了一个协议.这是它的代码:

#import <Foundation/Foundation.h>

@protocol myProtocol <NSObject>
    -(void) loadDataComplete;
@end
Run Code Online (Sandbox Code Playgroud)

现在我想调用这个方法,所以我做了以下代码:

firstViewController.h:

#import "myProtocol.h"

@interface firstViewController : UIViewController{
    id <myProtocol> delegate;
}
@property (retain) id delegate;
-(void) mymethod;
Run Code Online (Sandbox Code Playgroud)

firstViewController.m

@implementation firstViewController
@synthesize delegate;

- (void)viewDidLoad {
    [self mymethod];
}

-(void) mymethod {
    //some code here...
    [delegate loadDataComplete];
}
Run Code Online (Sandbox Code Playgroud)

我有另一个文件,其中也使用协议:

secondViewController.h:

#import "myProtocol.h"
@interface secondViewController : UIViewController<myProtocol>{
}
Run Code Online (Sandbox Code Playgroud)

secondViewController.m:

-(void) loadDataComplete{
    NSLog(@"loadDataComplete called");
}
Run Code Online (Sandbox Code Playgroud)

但我的secondViewController没有调用协议美联储.为什么会这样?任何建议将不胜感激.

objective-c ios

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

如何实现Realtor iPad应用程序中使用的自定义绘图搜索工具?

Realtor iPad应用程序在mapkit之上实现了一个自定义绘图工具,用于查询家庭区域.我熟悉mapkit及其相关的类,但我不知道如何用手指做一些自定义绘图并将其转换为地理空间查询.怎么做?

iphone mapkit mkmapview ipad ios

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

Apns php错误"无法连接到APNS:110连接超时."

我已经从这个Apns代码完成了php和Objective c的apns代码

并从此链接设置证书

用于向ios设备发送通知的沙箱和生产apns在我的服务器上运行完美.我将代码和相同的证书移动到客户端服务器,然后发送通知不起作用.

我调试所有的PHP代码,发现它停在这行代码

private function _connectSSLSocket($development) {
    $ctx = stream_context_create();
    stream_context_set_option($ctx, 'ssl', 'local_cert', $this->apnsData[$development]['certificate']);
    $this->sslStreams[$development] = stream_socket_client($this->apnsData[$development]['ssl'], $error, $errorString, 100, (STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT), $ctx);
    if(!$this->sslStreams[$development]){
        $this->_triggerError("Failed to connect to APNS: {$error} {$errorString}.");
        unset($this->sslStreams[$development]);
        return false;
    }
    return $this->sslStreams[$development];
}
Run Code Online (Sandbox Code Playgroud)

apns.log文件显示错误"无法连接到APNS:110连接超时".

没有弄错.为什么我会收到此错误而不向ios设备发送通知?任何人都可以指导我吗?

iphone apple-push-notifications ipad ios apns-php

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

删除uiviewcontroller的视图iPad的圆角

我必须从去除圆角UIViewUIViewcontroller。这是该图片在此处输入图片说明

我正在与详细视图

detailView.modalPresentationStyle = UIModalPresentationFormSheet;
Run Code Online (Sandbox Code Playgroud)

我想提出UIViewcontroller的观点不圆圆。有人对这个问题有想法吗?

uiviewcontroller uiview ipad presentmodalviewcontroller ios

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

是否可以将中心按钮放在iPhone上的UIToolBar上?

我想在UIToolBar的中心位置放一个按钮.我需要在以下代码中进行哪些更改?

CGRect toolbarFrame = CGRectMake(0, 0, self.view.frame.size.width, 44);
UIToolbar *mytoolbar = [[UIToolbar alloc] initWithFrame:toolbarFrame];
mytoolbar.autoresizingMask =  UIViewAutoresizingFlexibleWidth;
mytoolbar.tintColor = [UIColor blackColor];
UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithTitle:@"button 1"
                           style:UIBarButtonItemStylePlain target:self action:nil];
NSMutableArray *tools = [[NSMutableArray alloc] initWithObjects:button,nil];
[mytoolbar setItems:tools];
[self.view addSubview:mytoolbar];
Run Code Online (Sandbox Code Playgroud)

iphone uitoolbar

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

在多个ios设备之间共享应用商品订阅中的非续订

我的应用程序最近被itunes商店拒绝,原因如下.

11.6使用IAP的内容订阅必须至少持续7天,并且可供用户从其所有iOS设备使用

我通过以下链接 如何恢复不续订的Apple订阅

但没有得到如何在多个ios设备之间分享在app项目中购买的内容.我在应用商品中使用不续订.

任何好友都有这个想法.帮助将不胜感激.提前致谢.

storekit in-app-purchase ios

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

如何将像"2011-06-25T11:00:26 + 01:00"这样的日期字符串转换为像iPhone一样长的字符串?

我需要将此字符串日期"2011-06-25T11:00:26 + 01:00"转换为长期值.

我试过这个

NSDateFormatter *df = [[[NSDateFormatter alloc] init] autorelease];

[df setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];

[df setDateFormat:@"yyyy-MM-ddHH:mm:ssZ"];

NSDate *date = [df dateFromString:[time stringByReplacingOccurrencesOfString:@"T" withString:@""]];

[df setDateFormat:@"eee MMM dd, yyyy hh:mm"];

NSLog(@"time%@", time);
long lgTime =  (long)[date timeIntervalSince1970];
Run Code Online (Sandbox Code Playgroud)

但这不起作用.请帮我.

提前致谢.

iphone objective-c nsdate nsdateformatter

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