在界面构建器中,按住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) 我有两个名为"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'
有没有选择来检索所需的数据?
是否可以限制发布iOS应用程序的国家/地区?是否可以将版本限制在某个国家/地区?
如果是这样,我在哪里可以找到更多信息.我试图搜索文档,但无法找到关于此的决定性信息.提前致谢.
经过对StackOverflow的大量搜索后,它似乎只是在设备之前创建了一个4.0之前的VPN配置文件
我的问题是以下应用程序如何在没有root的情况下完成它?
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似乎没有.
更新3
请注意,这取自各种来源.似乎root是必需的,因为VpnService启动racoon,然后以系统用户身份运行,并从KeyStore中检索PSK.因此,其他应用程序创建的KeyStore条目对racoon不可见.(在linux环境中,racoon是一个协助IPSEC相关密钥协商的安全流程 - IKE).
这是有道理的,但仍有一些应用程序可以在没有root的情况下实现L2TP/IPSEC.
更新4
XinkVPN,源代码入门.仍然不允许用户创建L2TP配置文件而无需用户生成key_store并重新编译.不是很友好,但开始很棒.
我有一个标签,在我的应用程序中弹出显示点.我使用以下代码使标签的规模变大,然后变小.我还想将颜色从紫色变为绿色.有人能指出我实现这一目标的资源吗?
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) 我想知道如何区分用户点击提交或跳过内联后期流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) 我使用以下库将YouTube视频流式传输到Android应用程序.
我成功地通过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) 照片捕获仅在三星手机上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) 我有一个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)