iOS7上UITextField的leftView和rightView视图非常接近文本域边框.
如何为这些项添加一些(水平)填充?
我尝试修改框架,但没有工作
uint padding = 10;//padding for iOS7
UIImageView * iconImageView = [[UIImageView alloc] initWithImage:iconImage];
iconImageView.frame = CGRectMake(0 + padding, 0, 16, 16);
textField.leftView = iconImageView;
Run Code Online (Sandbox Code Playgroud)
请注意,我没有兴趣在文本字段的文本中添加填充,比如使用UITextBorderStyleNone为UITextField设置填充
我在mac上编写C++代码.编译时为什么会出现此错误?:
体系结构i386的未定义符号:"Log :: theString",引用自:libTest.a中的Log :: method(std :: string)(Log.o)ld:未找到体系结构i386 clang的符号:错误:链接器命令失败,退出代码为1(使用-v查看调用)
不确定我的代码是否错误或者我必须向Xcode添加其他标志.我当前的XCode配置是"静态库"项目的默认配置.
我的代码:
Log.h ------------
#include <iostream>
#include <string>
using namespace std;
class Log{
public:
static void method(string arg);
private:
static string theString ;
};
Run Code Online (Sandbox Code Playgroud)
Log.cpp ----
#include "Log.h"
#include <ostream>
void Log::method(string arg){
theString = "hola";
cout << theString << endl;
}
Run Code Online (Sandbox Code Playgroud)
我用测试代码调用'方法',这样:'Log :: method("asd"):'
谢谢你的帮助.
我正在播放几种声音:AudioServices
AudioServicesPlaySystemSound(aSystemSoundID);
当我在连接到机器的iPhone 3G上测试项目时,我收到以下消息:
> 2010-09-16 17:29:29.672
> myProject[6528:6def] [17:29:29.672
> <0x85d400>] PlaySound posting message
> to kill mediaserverd (5958) [Switching
> to thread 13059]
Run Code Online (Sandbox Code Playgroud)
和/或:
> 2010-09-16 17:30:28.316
> myProject[6528:6def] [17:30:28.316
> <0x85d400>] AudioQueueNew posting
> message to kill mediaserverd (0)
> Error: AudioQueueNewInput failed
> (0x10004003)
Run Code Online (Sandbox Code Playgroud)
知道为什么吗?
谢谢.
顺便说一句,在模拟器上一切正常.
我有这个代码:
- (NSString *) calculate: (uint) position {
static NSArray * localArray = [NSArray arrayWithArray: self.container.objects ];
// some un related code
return obj;
}
Run Code Online (Sandbox Code Playgroud)
编译器抱怨说:"Initializer元素不是编译时常量".它发生在我向localArray添加"static"时.但为什么?
我试图在我的一个xcode项目的构建时运行脚本.
方法1)我在我的当前"Build"方案中添加了一个预操作(运行脚本).它没有用,实际上它根本没有运行.
方式2)然后我将相同的脚本添加到目标("目标",构建阶段seciton).它按预期运行.
问题:
1)为什么前动作脚本没有运行?(我尝试过"电子邮件操作",它确实有效)
2)在"方案"和"构建阶段"中设置脚本有什么区别?我的猜测是,对于最后一个它总是会运行(在构建时),而不关心当前的方案,那有什么不同吗?
有趣的事实:当我编辑Build> pre-action部分时,Xcode崩溃了
我确保选择了正确的方案.
Xcode版本4.4.1(4F1003)
我想在后台线程中运行一个方法,第一个方法将在几秒钟后在同一个(后台)线程上运行另一个方法.我写了这个:
- (IBAction)lauch:(id)sender
{
[self performSelectorInBackground:@selector(first) withObject:nil];
}
-(void) second {
printf("second\n");
}
-(void) first {
NSAutoreleasePool *apool = [[NSAutoreleasePool alloc] init];
printf("first\n");
[self performSelector:@selector(second) withObject:nil afterDelay:3];
printf("ok\n");
[apool release];
}
Run Code Online (Sandbox Code Playgroud)
但第二种方法从未被调用,为什么?而且,我怎么可以实现我的目标?
谢谢
这段代码给了我EXC_BAD_ACCESS,为什么?
NSMutableDictionary *d = [[NSMutableDictionary alloc] init];
IMP imp= [d methodForSelector:@selector(setObject:forKey:) ];
imp(d, @selector( setObject:forKey:), @"obj", @"key");
Run Code Online (Sandbox Code Playgroud)
我刚刚开始使用IMP,第一次尝试..没有运气.不知道为什么我得到错误,也..在过去,当我得到EXC_BAD_ACCESS时,消息在控制台打印,这次错误行突出显示.
一些注意事项:ARC已启用,XCode 4.3.2,该项目使用Objective-C++作为默认语言/编译器,此代码位于项目的最开始
多谢你们
我正在自动化iOS项目的构建过程.一切都很好......但现在我必须支持iOS 4,我安装的是iOS模拟器4.3(Xcode:Preferences> Downloads> Components).
在xcode里面我有以下选项:
没有 4.3
从命令行
$ xcodebuild -showsdks
Mac OS X SDKs:
Mac OS X 10.6 -sdk macosx10.6
Mac OS X 10.7 -sdk macosx10.7
iOS SDKs:
iOS 5.0 -sdk iphoneos5.0
iOS Simulator SDKs:
Simulator - iOS 5.0 -sdk iphonesimulator5.0
Run Code Online (Sandbox Code Playgroud)
没有 4.3
问题:
多谢你们.
我需要将一些设置文件放入“工作目录”中才能配置我的应用程序。
我尝试将其放入 ./WEB-INF/ 但没有成功,知道“工作目录”在哪里吗?以及,这是一种以编程方式获取它的方法吗?
谢谢。
我是iphone和Objective c的新手,到目前为止,我已经能够编写一些小例子了.
我想播放声音,并在示例完成播放后继续使用其余代码,即:
printf("hello");
playASound["file.wav"];
printf("world");
Run Code Online (Sandbox Code Playgroud)
实际上我得到了:打印你好,同时播放文件和打印世界,但我想要的是:打印你好,播放文件,打印世界......所以,问题是我如何得到它?
谢谢
顺便说一句.这是playASound代码:
-(void) playASound: (NSString *) file {
//Get the filename of the sound file:
NSString *path = [NSString stringWithFormat:@"%@/%@",
[[NSBundle mainBundle] resourcePath],
file];
SystemSoundID soundID;
//Get a URL for the sound file
NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO];
AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID);
//play the file
AudioServicesPlaySystemSound(soundID);
}
Run Code Online (Sandbox Code Playgroud) objective-c ×6
ios ×4
iphone ×3
xcode ×3
apache ×1
c++ ×1
clang ×1
core-audio ×1
ios5 ×1
java ×1
macos ×1
tomcat ×1
tomcat5.5 ×1
uitextfield ×1
xcode4 ×1
xcode4.2 ×1
xcodebuild ×1