我的目标是在屏幕上获取当前位置(在表格的外侧),然后按"C"保存X,Y坐标.
我谷歌并发现了一些使用api钩子的建议,但我想知道有没有办法可以完全用C#代码(.NET Lib)来完成这个任务?
如果可能的话请给我快速的样品,因为我是c#的新手.
谢谢
这个问题最近一直困扰着我.任何帮助,将不胜感激.
这些是我的目标:
到目前为止,我已经完成了所有这些,我可以看到选择器工作正常.每当我更改选择器值时,我都会使用NSLog来显示当前值,并且每次更改都能正常工作.
这就是我想要的东西: **每当我改变pickervalue,我需要的价值,也可以在的UITextField(这是在UITableViewCell中)自动改变**
这是我的CellForRowIndexPath代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(110, 10, 185, 30)];
textField.clearsOnBeginEditing = YES;
textField.textAlignment = UITextAlignmentRight;
[cell.contentView addSubview:textField];
UIDatePicker *datePicker = [[UIDatePicker alloc] init];
datePicker.datePickerMode = UIDatePickerModeDate;
[datePicker addTarget:self action:@selector(datePickerValueChangedd:) forControlEvents:UIControlEventValueChanged];
datePicker.tag = indexPath.row;
textField.inputView = datePicker;
NSDateFormatter *df = [[NSDateFormatter alloc] init];
df.dateStyle = NSDateFormatterMediumStyle; …Run Code Online (Sandbox Code Playgroud) 当我将按钮设置为禁用时,文本变为灰色(之前为黑色).在我的窗口中,结果是禁用按钮时文本不可读.
我查看了NSButton/NSButtonCell/NSCell/NSControl的文档,但我没有找到任何方法将文本保持黑色.你知道我怎么做吗?
我正在尝试在Obj-c运行时引用中找到此方法
BOOL class_addMethod(Class cls, SEL name, IMP imp, const char *types)
Run Code Online (Sandbox Code Playgroud)
我想添加一个新的方法,如:
- [AClass drawWithFrame:(NSRect)rect inView:(id)view]
Run Code Online (Sandbox Code Playgroud)
到目前为止,我已经编写了一个C函数:
void drawWithFrameInView(id this, SEL this_cmd, NSRect frame, id view){
...
}
Run Code Online (Sandbox Code Playgroud)
现在我准备做了:
BOOL success = class_addMethod(NSClassFromString(@"AClass"),
@selector(drawWithFrame:inView:),
(IMP)drawWithFrameInView,
"v@:@:@:");
Run Code Online (Sandbox Code Playgroud)
但是success从来没有,我尝试了同样的方法,使用更简单的签名方法,并且它有效.所以我认为问题是最后一个参数:"v@:@:@:"
在这种情况下我应该通过什么才能使我的新方法有效?
我有一个相当冗长的if声明.if语句检查字符串"type"以确定应该实例化的对象类型.这是一个样本......
if ( [type rangeOfString:@"coin-large"].location != NSNotFound )
{
... create large coin ...
mgr = gameLayer.coinLargeMgr;
}
else if ( [type rangeOfString:@"coin-small"].location != NSNotFound )
{
mgr = gameLayer.coinLargeMgr;
}
... more else statements ...
myObject = [mgr getNewObject];
Run Code Online (Sandbox Code Playgroud)
"else-if"语句继续用于其他目前约为20的对象类型,并且该数字可能会增加.这很有效,但在维护和效率方面,我认为可以改进.我现在的主要候选人是创建一个NSDictionary键入对象类型字符串(coin-small,coin-large等)以及应该绑定到该类型的manager对象的值.我的想法是,这将是我需要创建的对象类型的快速查找.不确定这是最好的方法,继续看其他选项,但很好奇这里的人们可能为类似的问题做了什么.非常感谢任何帮助/反馈.
我正在构建一个以XML格式公开数据的REST API.我的域层中有一大堆域类,供API背后的服务层和我们将提供给客户的客户端API使用.(客户可以选择直接与REST API交互,但客户端API简化了事情).我希望保持我的域类清除任何数据持久性逻辑,但我试图弄清楚域类是否可以实现IXmlSerializable以帮助简化序列化通过和检索的数据的过程. API.我开始认为我保持域类没有任何序列化逻辑,而是用序列化行为装饰它们,例如将域对象包装在处理序列化的对象中.我的事情比他们需要的更复杂吗?有关如何处理此问题的任何想法?谢谢!
我有一个字符串
"1.898, -1.456, 233.556, 34546.8"
Run Code Online (Sandbox Code Playgroud)
如何在C#中创建一个双打数组我是否必须使用正则表达式或拆分函数?
我在尝试这样的事情:
string[] aux = ORIGINALtext.Split(',');
foreach (string val in aux)
{
double value = double.Parse(val);
Console.WriteLine(value);
}
Run Code Online (Sandbox Code Playgroud) 我有两张桌子
T1
id name
1 saanu
3 abc
Run Code Online (Sandbox Code Playgroud)
delT1
id name
2 val2
4 val4
Run Code Online (Sandbox Code Playgroud)
我必须从两个表中找出id(int)的最大值.
我是Grails标准建设者的新手,有人可以解释以下是什么意思吗?
def c = Account.createCriteria()
def results = c {
like("holderFirstName", "Fred%")
and {
between("balance", 500, 1000)
eq("branch", "London")
}
maxResults(10)
order("holderLastName", "desc")
}
Run Code Online (Sandbox Code Playgroud)
这是不是意味着
Select * from account where
holderFirstName like 'fred%' and
(balance between 500 and 1000 **and**
branch='london")Select * from account where
holderFirstName like 'fred%' and
(balance between 500 and 1000 **or**
branch='london")如果我想一起使用"或"和"和",我该怎么做?
所以我有一个NSArray有文件名称的文件UITableView.将NSString在S NSArray有空格这样一个条目会是什么样子,"约翰·史密斯".然后我有对应于每个表条目的pdf.这些pdf条目名称不同.它们就像是"JohnSmith.pdf".我创建了一个方法,基本上将名称转换为pdfs,以呈现适当的pdf.在我的方法中,我基本上硬编码了值
NSUInteger loopCount = 0;
for ( ; loopCount < [array count]; loopCount++) {
if ([[array objectAtIndex:loopCount] isEqualToString:@"John Smith"]) {
[array replaceObjectAtIndex:loopCount withObject:@"JohnSmith.pdf"];
}
}
Run Code Online (Sandbox Code Playgroud)
有一个更好的方法吗?这就是我所能想到的,因为数据已经被赋予了不同的名称.谢谢.
专家在决定稳定的java版本时需要一些帮助.我们计划将我们的应用程序从java 1.4移动到1.6,哪个版本的Java 1.6更稳定.
我想在我的应用中使用活动指示器.
我在我的应用程序中使用JSON解析.首先,当我显示数据下载活动指示器时单击同步按钮,下载完成时停止.
同样isuue在这里,当应用程序启动数据下载时,我也在应用程序中放置活动指示器.
我正在使用以下方法进行连接...
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
}
Run Code Online (Sandbox Code Playgroud) 为什么这段代码会产生内存泄漏?
- (void)loadModalInfo
{
InformationScreenViewController *infoView = [[InformationScreenViewController alloc] init];
infoView.url = [[NSBundle mainBundle] URLForResource:@"NewPatientInfo" withExtension:@"html"]; // LEAKING
// [infoView setModalPresentationStyle:UIModalPresentationFormSheet];
[infoView setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentModalViewController:infoView animated:YES];
[infoView release];
infoView = nil;
}
Run Code Online (Sandbox Code Playgroud)
我是使用仪器的新手,我无法弄清楚为什么代码泄漏.提前致谢.
objective-c ×7
c# ×3
iphone ×3
cocoa ×2
arrays ×1
criteria ×1
grails ×1
java ×1
jdk1.6 ×1
macos ×1
memory-leaks ×1
regex ×1
select ×1
split ×1
sql ×1
string ×1
uidatepicker ×1
uipickerview ×1
xcode ×1