我UIView在我的应用程序中使用动画:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
//do some animation
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)
现在,动画可能需要几秒钟才能完成.那么,有没有办法知道动画何时结束?
我正在使用我的应用程序NSURLConnection获取网站的网页.
我怎么称呼NSURLConnection
NSURL *url = [NSURL URLWithString:@"http://jokes.moment.co.il/default.asp?s1=4&s2=0"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[NSURLConnection connectionWithRequest:request delegate:self];
Run Code Online (Sandbox Code Playgroud)
这是我如何附加我得到的数据:
-(void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
if (receivedData)
{
[receivedData appendData:data];
}
else
{
receivedData = [[NSMutableData alloc] initWithData:data];
}
}
Run Code Online (Sandbox Code Playgroud)
这就是我尝试将其转换为NSString的方式:
-(void) connectionDidFinishLoading:(NSURLConnection *)connection
{
NSString *string = [[NSString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding];
}
Run Code Online (Sandbox Code Playgroud)
receivedData是47586字节,当我做转换时,字符串是nil
我下载了一个html页面,我尝试将它从NSData编码为NSString:
NSString *string = [[NSString alloc] initWithData:receivedData encoding:NSISOLatin1StringEncoding];
Run Code Online (Sandbox Code Playgroud)
我发现它给出了一个带有奇怪字符的文本.我发现浏览器中的页面看起来不错
WINDOWS-1255 ISO-8858-8
它是否存在objective-c中支持它的编码?
我使用此代码编写用作本地 http 请求服务器的 Windows 服务。
public void StartMe()
{
System.Net.IPAddress localAddr = System.Net.IPAddress.Parse("127.0.0.1");
System.Net.Sockets.TcpListener server = new System.Net.Sockets.TcpListener(localAddr, 1234);
server.Start();
Byte[] bytes = new Byte[1024];
String data = null;
while (RunThread)
{
System.Net.Sockets.TcpClient client = server.AcceptTcpClient();
data = null;
System.Net.Sockets.NetworkStream stream = client.GetStream();
stream.Read(bytes, 0, bytes.Length);
data = System.Text.Encoding.ASCII.GetString(bytes);
System.IO.StreamWriter sw = new System.IO.StreamWriter("c:\\MyLog.txt", true);
sw.WriteLine(data);
sw.Close();
client.Close();
}
}
Run Code Online (Sandbox Code Playgroud)
我对这段代码有一些问题:首先,data在我在浏览器中写下这个 URL 后,在字符串中我得到了这样的东西http://127.0.0.1:1234/helloWorld
GET /helloWorld HTTP/1.1
Host: 127.0.0.1:1234
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows …Run Code Online (Sandbox Code Playgroud) 我有UIView一些相同习惯的子视图UIView.在我将它们添加到Main之后UIView我也将它添加到数组中,当我完成添加它们时,我想检查是否有一些UIViews重叠,所以我检查它:
bool CGRectIntersectsRect(CGRect rect1, CGRect rect2)
Run Code Online (Sandbox Code Playgroud)
我的问题是我想知道CGRect重叠是什么,因为我想用另一种背景颜色绘制它,有没有现成的方法来检测它?
我TextView用const字符串放置了一个布局.字符串很长所以我定义了两行TextView.问题是第二行从右边开始而不是从中心开始.我怎么能把TextView它从中心对齐
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/str_item"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_gravity="center_horizontal" android:lines="2" android:textColor="@color/Red"/>
Run Code Online (Sandbox Code Playgroud) 我尝试转换字符串:
3033547640189791162
Run Code Online (Sandbox Code Playgroud)
用这种方法:
NSNumber * myNumber = [NSNumber numberWithDouble:[tmpId doubleValue]];
Run Code Online (Sandbox Code Playgroud)
还有这个 :
NSNumberFormatter * f = [[NSNumberFormatter alloc] init];
[f setNumberStyle:NSNumberFormatterNoStyle];
NSNumber * myNumber = [f numberFromString:tmpId];
[f release];
Run Code Online (Sandbox Code Playgroud)
他们俩给我这个号码:
<CFNumber 0x13a2b0 [0x3f54c9f8]>{value = +3033547640189791232.00000000000000000000, type = kCFNumberFloat64Type}
Run Code Online (Sandbox Code Playgroud)
注意:
<CFNumber 0x1b5550 [0x3f54c9f8]>{value = +3033547640189791232, type = kCFNumberSInt64Type}
Run Code Online (Sandbox Code Playgroud)
当我尝试使用时:
NSString *tmpId = @""3033547640189791162";
long i = [tmpId longLongValue];
Run Code Online (Sandbox Code Playgroud)
我等于= -1631802438
int i = [tmpId intValue];
Run Code Online (Sandbox Code Playgroud)
我等于= 2147483647
所以我失去了原来的数字值
我在我的应用程序LongListSelector中,这是我如何设置项目源:
historylist.ItemsSource = new List<VideoItem>(historyRep.historyArray);
Run Code Online (Sandbox Code Playgroud)
现在,如果从数组中删除了一个项目,则会添加一个新项目或者编辑的任何项目我再次调用此方法来刷新ItemSource:
historylist.ItemsSource = new List<VideoItem>(historyRep.historyArray);
Run Code Online (Sandbox Code Playgroud)
但现在我注意到这个方法产生了一些问题,我想知道这是否是刷新\更新LongListSelector的好方法?
我使用以下代码从SQL Server表中进行选择:
using (SqlConnection con = new SqlConnection(SqlConnectionString))
{
string sql = @"SELECT * FROM movies WHERE title like '%' + '" + searchQuery + "' + '%'";
using (var command = new SqlCommand(sql, con))
{
con.Open();
using (var reader = command.ExecuteReader())
{
while (reader.Read())
{
....
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
并且它工作得很好,但我想阻止SQL注入,所以我尝试使用:
using (SqlConnection con = new SqlConnection(SqlConnectionString))
{
string sql = @"SELECT * FROM movies WHERE title like '%' '@Search' + '%'";
using (var command = new SqlCommand(sql, con)) …Run Code Online (Sandbox Code Playgroud) 我正在尝试与我的 android 应用程序共享链接:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, share);
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "");
mContext.startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
这是share强:
Check out my link:\n http://my123domain.com/v.php?vid=123456-123456-123456
Run Code Online (Sandbox Code Playgroud)
但是当我Whats App通过链接分享它时无法点击,知道为什么吗?
iphone ×5
objective-c ×5
c# ×3
.net ×2
android ×2
java ×2
animation ×1
ios ×1
silverlight ×1
sql ×1
sql-server ×1
whatsapp ×1
wpf ×1