小编Oh *_*Boy的帖子

iOS:UIButton根据文本长度调整大小

在界面构建器中,按住Command+ =将调整按钮的大小以适合其文本.我想知道在按钮添加到视图之前是否可以以编程方式执行此操作.

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button.titleLabel setFont:[UIFont fontWithName:@"Arial-BoldMT" size:12]];
[button addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside];
// I need to know the width needed to accomodate NSStringVariable
[button setTitle:NSStringVariable forState:UIControlStateNormal]; 
// So that I can set the width property of the button before addSubview
[button setFrame:CGRectMake(10, 0, width, fixedHeight)];
[subNavigation addSubview:button];
Run Code Online (Sandbox Code Playgroud)

uibutton ios

126
推荐指数
11
解决办法
13万
查看次数

核心数据:NSPredicate用于多对多关系.("这里不允许使用多个键")

我有两个名为"Category"和"Article"的实体,它们有很多关系.我想形成一个谓词,搜索category.name等于某个值的所有文章.我有以下内容:

 NSEntityDescription  *entityArticle   = [NSEntityDescription entityForName:@"Article" inManagedObjectContext:managedObjectContext]; 
 NSSortDescriptor  *sortDescriptor   = [[NSSortDescriptor alloc] initWithKey:@"title" ascending:YES];
 NSArray     *sortDescriptors  = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
 NSPredicate    *predicate    = [NSPredicate predicateWithFormat:@"categories.name == [cd] %@", category.name]; 

 [request setSortDescriptors:sortDescriptors];
 [request setEntity:entityArticle];
 [request setPredicate:predicate];

 NSMutableArray *results = [[managedObjectContext executeFetchRequest:request error:nil] mutableCopy];

 if ([results count] > 0)
  NSLog(@"Results found."); 
 else 
  NSLog(@"NO results found."); 

 [request release];
 [sortDescriptor release];
 [sortDescriptors release];
Run Code Online (Sandbox Code Playgroud)

我收到的错误是 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'to-many key not allowed here'

有没有选择来检索所需的数据?

core-data nspredicate ios

63
推荐指数
2
解决办法
3万
查看次数

如何在iOS上检索UDID?

我想知道是否有可能找到用户iPhone的UDID.有人可以解释一下吗?

cocoa-touch udid ios

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

可以限制发布iOS应用程序的国家/地区吗?

是否可以限制发布iOS应用程序的国家/地区?是否可以将版本限制在某个国家/地区?

如果是这样,我在哪里可以找到更多信息.我试图搜索文档,但无法找到关于此的决定性信息.提前致谢.

ios

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

现有VPN应用程序如何在Android 2.0 - 2.3中创建新配置文件?

经过对StackOverflow的大量搜索后,它似乎只是在设备之前创建了一个4.0之前的VPN配置文件

我的问题是以下应用程序如何在没有root的情况下完成它?

http://www.featvpn.com/

https://play.google.com/store/apps/details?id=com.expressvpn.vpn&hl=en

更新1

似乎私有API是4.0之前的方式.不幸的是,没有太多资源可以开始使用.有谁知道私人api是否还需要root设备?

更新2

看来你可以使用改进的Android.jar或使用反射来做到这一点.L2TP/IPSEC仍然需要root设备.PPTP似乎没有.

如何在Android上使用内部API

更新3

请注意,这取自各种来源.似乎root是必需的,因为VpnService启动racoon,然后以系统用户身份运行,并从KeyStore中检索PSK.因此,其他应用程序创建的KeyStore条目对racoon不可见.(在linux环境中,racoon是一个协助IPSEC相关密钥协商的安全流程 - IKE).

这是有道理的,但仍有一些应用程序可以在没有root的情况下实现L2TP/IPSEC.

更新4

XinkVPN,源代码入门.仍然不允许用户创建L2TP配置文件而无需用户生成key_store并重新编译.不是很友好,但开始很棒.

https://github.com/xinthink/xinkvpn

http://code.google.com/p/xinkvpn/

vpn android

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

iPad:动画UILabels变色

我有一个标签,在我的应用程序中弹出显示点.我使用以下代码使标签的规模变大,然后变小.我还想将颜色从紫色变为绿色.有人能指出我实现这一目标的资源吗?

mLabel.textColor = [UIColor purpleColor];

 [UIView beginAnimations:nil context:NULL];
 [UIView setAnimationDuration:1.0];
 [UIView setAnimationDelegate:self];
 mLabel.transform = CGAffineTransformMakeScale(1.5,1.5);
 [UIView setAnimationRepeatCount:1];
 mLabel.transform = CGAffineTransformMakeScale(0.5,0.5);
 mLabel.textColor = [UIColor greenColor];
 [UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)

iphone animation ios

19
推荐指数
3
解决办法
2万
查看次数

Facebook Connect for iOS:dialogDidComplete响应差异化

我想知道如何区分用户点击提交或跳过内联后期流FBDialog.谁知道要测试什么?

我在iOS 4.2环境中使用最新的iOS Facebook Connect.

/**
 * Called when a UIServer Dialog successfully return.
 */
- (void)dialogDidComplete:(FBDialog *)dialog {
    if user tapped submit and post was successful
        alert user of successful post

    if user tapped "skip" (cancel equivalent)
        do not display alert
}
Run Code Online (Sandbox Code Playgroud)

facebook ios

16
推荐指数
2
解决办法
4764
查看次数

流式传输到VideoView只能在使用三星手机时在Wifi上播放

我使用以下库将YouTube视频流式传输到Android应用程序.

http://code.google.com/p/android-youtube-player/source/browse/trunk/OpenYouTubeActivity/src/com/keyes/youtube/OpenYouTubePlayerActivity.java?r=3

我成功地通过3G和Wifi在HTC和摩托罗拉手机上播放视频.但是,在三星Galaxy(Epic 4G)和三星Galaxy II手机上,我只能使用Wifi播放.3G给了我这个错误:"无法播放视频.抱歉,此视频无法播放."

我尝试过强制低质量的YouTube流媒体,但这并没有帮助.我在日志中看到Start()两种情况都被调用(3G/Wifi).这是VideoView的问题吗?有解决方法吗?

编辑2

这些视频来自YouTube API.我尝试使用嵌入式和普通流,以及可用的最低质量流(每个视频不同).此外,我不认为这是一个编码问题,因为相同的视频使用Wifi正确播放.

编辑1

无论使用Wifi还是不使用3G,我都会收到以下输出.

01-30 15:22:38.305: E/MediaPlayer(3831): error (1, -1)
01-30 15:22:38.305: E/MediaPlayer(3831): callback application
01-30 15:22:38.305: E/MediaPlayer(3831): back from callback
01-30 15:22:38.309: E/MediaPlayer(3831): Error (1,-1)
Run Code Online (Sandbox Code Playgroud)

根据这个链接,这些错误意味着以下(我认为):

/*
 Definition of first error event in range (not an actual error code).
 */
const PVMFStatus PVMFErrFirst = (-1);
/*
 Return code for general failure
 */
const PVMFStatus PVMFFailure = (-1);
/*

/*
 Return code for general success
 */
const PVMFStatus PVMFSuccess …
Run Code Online (Sandbox Code Playgroud)

streaming android android-videoview

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

照片捕获Intent仅在Samsung手机上导致NullPointerException

照片捕获仅在三星手机上Intent造成NullPointerException.

实施如下.

final Button capture = (Button)findViewById(R.id.capture_button);
capture.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);

    }
});


protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
    if (requestCode == CAMERA_PIC_REQUEST) {  

        Bitmap thumbnail = (Bitmap)data.getExtras().get("data");
        ImageView image = (ImageView)findViewById(R.id.photoResultView);
        image.setImageBitmap(thumbnail);
    }
}
Run Code Online (Sandbox Code Playgroud)

camera android nullpointerexception

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

通过scrollOffset查找最接近的锚点href

我有一个UIWebViewHTML页面完全加载.它UIWebView有一个320 x 480的框架并水平滚动.我可以获得用户当前所在的当前偏移量.我想使用XY偏移找到最近的锚点,这样我就可以"跳转到"锚定位置.这是可能吗?有人能指点我使用Javascript中的资源吗?

<a id="p-1">Text Text Text Text Text Text Text Text Text<a id="p-2">Text Text Text Text Text Text Text Text Text ... 
Run Code Online (Sandbox Code Playgroud)

更新

我超级难过的JS代码:

function posForElement(e)
{
    var totalOffsetY = 0;

    do
    {
        totalOffsetY += e.offsetTop;
    } while(e = e.offsetParent)

    return totalOffsetY;
}

function getClosestAnchor(locationX, locationY)
{
    var a = document.getElementsByTagName('a');

    var currentAnchor;
    for (var idx = 0; idx < a.length; ++idx)
    {
        if(a[idx].getAttribute('id') && a[idx+1])
        {
            if(posForElement(a[idx]) <= locationX && locationX <= posForElement(a[idx+1])) 
            { …
Run Code Online (Sandbox Code Playgroud)

javascript anchor uiwebview

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