我正在做一个关于在Xcode中调试的演示文稿,并希望获得有关使用NSLog的更多信息.
特别是,我有两个问题:
我有一个UITableView5 UITableViewCells.每个单元格包含一个UIButton设置如下:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *identifier = @"identifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil) {
cell = [[UITableView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
[cell autorelelase];
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(10, 5, 40, 20)];
[button addTarget:self action:@selector(buttonPressedAction:) forControlEvents:UIControlEventTouchUpInside];
[button setTag:1];
[cell.contentView addSubview:button];
[button release];
}
UIButton *button = (UIButton *)[cell viewWithTag:1];
[button setTitle:@"Edit" forState:UIControlStateNormal];
return cell;
}
Run Code Online (Sandbox Code Playgroud)
我的问题是:在buttonPressedAction:方法中,我如何知道按下了哪个按钮.我考虑过使用标签,但我不确定这是最好的路线.我希望能够以某种方式标记indexPath到控件上.
- (void)buttonPressedAction:(id)sender
{
UIButton *button = (UIButton …Run Code Online (Sandbox Code Playgroud) 我想在UITableView中设置第一个标题的高度.对于其他标题,我希望它们保持默认高度.在下面的代码中,我可以用什么值/常数代替"someDefaultHeight"?
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if (section == 0)
return kFirstHeaderHeight;
return someDefaultHeight;
}
Run Code Online (Sandbox Code Playgroud)
谢谢
给定字符串中的URL:
http://www.example.com/test.xml
Run Code Online (Sandbox Code Playgroud)
将文件内容从服务器(由url指向)下载到C#中的字符串中,最简单/最简洁的方法是什么?
我现在这样做的方式是:
WebRequest request = WebRequest.Create("http://www.example.com/test.xml");
WebResponse response = request.GetResponse();
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
Run Code Online (Sandbox Code Playgroud)
这是很多代码,基本上可以是一行:
string responseFromServer = ????.GetStringFromUrl("http://www.example.com/test.xml");
Run Code Online (Sandbox Code Playgroud)
注意:我不担心异步调用 - 这不是生产代码.
我有一个朋友刚刚开始使用Java开发.NET开发很长时间,在查看了他的一些代码后,我注意到他经常做以下事情:
IDictionary<string, MyClass> dictionary = new Dictionary<string, MyClass>();
Run Code Online (Sandbox Code Playgroud)
他将字典声明为接口而不是类.通常我会做以下事情:
Dictionary<string, MyClass> dictionary = new Dictionary<string, MyClass>();
Run Code Online (Sandbox Code Playgroud)
我只在需要时使用IDictionary接口(例如,将字典传递给接受IDictionary接口的方法).
我的问题是:他的做事方式有什么优点吗?这是Java中的常见做法吗?
我想使用TSQL确定表的主键(存储过程或系统表很好).SQL Server(2005或2008)中是否存在这样的机制?
我需要一些关于创建UITableViewCell的指导,左边有一个可以切换的图像.图像应该是可插拔的,并充当切换(复选框).
我正在努力的部分是:
有关示例,请参见下图:
替代文字http://img208.yfrog.com/img208/6119/screenshotkmr.png
谢谢
鉴于以下内容:
string file = @"c:\somepath\somefile.dll";
Run Code Online (Sandbox Code Playgroud)
如何使用.NET查找该DLL的文件和产品版本号?
dll可以是本机的或托管的.
谢谢.
我正在尝试在C#(.NET 3.5 SP1)中创建一个透明按钮,以便在我的WinForms应用程序中使用.我已经尝试了一切让按钮变得透明(它应该显示按钮下方的渐变背景)但它只是不起作用.
这是我正在使用的代码:
public class ImageButton : ButtonBase, IButtonControl
{
public ImageButton()
{
this.SetStyle(
ControlStyles.SupportsTransparentBackColor |
ControlStyles.OptimizedDoubleBuffer |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.ResizeRedraw |
ControlStyles.UserPaint, true);
this.BackColor = Color.Transparent;
}
protected override void OnPaint(PaintEventArgs pevent)
{
Graphics g = pevent.Graphics;
g.FillRectangle(Brushes.Transparent, this.ClientRectangle);
g.DrawRectangle(Pens.Black, this.ClientRectangle);
}
// rest of class here...
}
Run Code Online (Sandbox Code Playgroud)
问题是该按钮似乎是从某个地方抓取随机UI内存并从Visual Studio的UI中填充一些缓冲区(在设计模式下).在运行时它会抓住一些零缓冲区并且完全是黑色的.
我的最终目标是在隐形按钮而不是矩形上绘制图像.然而,这个概念应该保持不变.当用户将鼠标悬停在按钮上时,则绘制按钮类型的形状.
有任何想法吗?
编辑:谢谢大家,以下为我工作:
public class ImageButton : Control, IButtonControl
{
public ImageButton()
{
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
SetStyle(ControlStyles.Opaque, true);
SetStyle(ControlStyles.ResizeRedraw, true);
this.BackColor = Color.Transparent;
}
protected override void OnPaint(PaintEventArgs pevent) …Run Code Online (Sandbox Code Playgroud) 我是否需要释放Core Foundation对象以清理内存?如果是这样,怎么样?
例如,在代码中:
ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef peopleArray = ABAddressBookCopyArrayOfAllPeople(addressBook);
Run Code Online (Sandbox Code Playgroud)
我需要发布peopleArray吗?怎么样addressBook?
c# ×4
cocoa-touch ×4
iphone ×3
uitableview ×3
.net ×2
cocoa ×2
objective-c ×2
button ×1
dll ×1
gdi+ ×1
http ×1
interface ×1
ios ×1
java ×1
networking ×1
nslog ×1
primary-key ×1
sql ×1
sql-server ×1
t-sql ×1
uibutton ×1
versioning ×1
winforms ×1
xcode ×1