попробуйте
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="@color/color_white"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:id="@+id/ErrorImageView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="@dimen/cards_error_image_margin_top"
android:layout_weight="1"
android:adjustViewBounds="true"
android:scaleType="fitCenter" />
<TextView
android:id="@+id/ErrorTextView"
style="@style/CustomFont30Marine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/cards_error_text_margin_top"
android:gravity="center_horizontal" />
<Button
android:id="@+id/RetryButton"
style="@style/WhiteCustomButton"
android:layout_width="@dimen/cards_error_retry_button_width"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/cards_error_retry_button_margin_bottom" />
</LinearLayout>
Да, используйте UIWebView и поместите статический HTML в него.
Как так:
[myWebView loadHTMLString:@"<html><head></head><body style=\"font-family: sans-serif;\"> .... </body></html>" baseURL:nil];
Можно инициировать сафари путем вызова UIApplication openURL: метод с URL Вы хотите отобразиться. Это закроет Ваше приложение и затем откроет сафари (или почта / YouTube / и т.д.).
Вы захотите сделать свою ссылку так или иначе, возможно, в кнопке. Та часть ваше дело.
Если Вы хотите встроить содержимое HTML в свое представление, то любой ценой используют UIWebView.
Документация:
Спасибо Frank и Ryan.
В дополнение к направлению Frank's я также должен был реализовать UIWebViewDelegate и связаться с ним в Интерфейсном Разработчике. Причина состояла в том, что каждая ссылка, на которую нажали, откроется в моем приложении (без навигации, возможной...). Я только должен был реализовать этот метод, который открывает каждый URL с соответствующим приложением:
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
if (navigationType == UIWebViewNavigationTypeLinkClicked) {
[[UIApplication sharedApplication] openURL:request.URL];
return false;
}
return true;
}
To launch the web browser at the specified url:
NSURL *target = [[NSURL alloc] initWithString:@"http://www.stackoverflow.com"];
[[UIApplication sharedApplication] openURL:target];
This code can be run anywhere. I sub-classed UILabel, added the touchedsEnded method and place it in there. (Don't forget to set labelname.userInteractionEnabled = YES;)
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
NSURL *target = [[NSURL alloc] initWithString:@"http://www.stackoverflow.com"];
[[UIApplication sharedApplication] openURL:target];
}