我正在创建一个标签栏iOS应用程序.标签栏视图控制器有两个选项卡,每个选项卡都连接到视图控制器.
这看起来如何:

我需要向选项卡控制器添加更多选项卡.我在故事板上做的如下:
我认为这是做到这一点的方法,但在此之后标签栏控制器没有显示任何标签图标,标签栏变为灰色.
像这样:

我需要知道我做错了什么.
经过长时间的阅读和检查代码,我很自豪有一个自定义表视图,其中包含部分和部分标题,所有部分都来自核心数据对象.现在我需要自定义部分标题和背景颜色.我已经看到它已经完成但是在一种viewForHeaderInSection方法中.在我的titleForHeaderInSection方法中是不可能的?在这里你有我的方法:
-(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
id <NSFetchedResultsSectionInfo> theSection = [[self.fetchedResultsController sections]objectAtIndex:section];
NSString *sectionname = [theSection name];
if ([sectionname isEqualToString:@"text 1"]){
return @"Today";
}
else if ([sectionname isEqualToString:@"text 2"]){
return @"Tomorrow";
}
if ([[self.fetchedResultsController sections]count]>0){
id<NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections]objectAtIndex:section];
return [sectionInfo name];
}
else{
return nil;
}
}
Run Code Online (Sandbox Code Playgroud) 我试图根据日期属性过滤核心数据对象.
这是我目前的代码:
func getFetchedResultController(selectedEntity: NSString){
let appDelegate : AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
let managedObjectContext: NSManagedObjectContext = appDelegate.managedObjectContext!
let fetchRequest = NSFetchRequest()
let entity = NSEntityDescription.entityForName(selectedEntity as String, inManagedObjectContext: managedObjectContext)
fetchRequest.entity = entity
fetchRequest.fetchBatchSize = 20
let date = NSDate()
let sectionSortDescriptor = NSSortDescriptor(key: "timeStamp < %@",date)
let sortDescriptors = [sectionSortDescriptor] //, secondSortDescriptor]
fetchRequest.sortDescriptors = sortDescriptors
let aFetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: managedObjectContext, sectionNameKeyPath: nil, cacheName: nil)
aFetchedResultsController.delegate = self
self.fetchedResultsController = aFetchedResultsController
var error: NSError? = nil
if !self.fetchedResultsController.performFetch(&error) …Run Code Online (Sandbox Code Playgroud) 我使用以下方法将图像从Android上传到服务器.
public void uploadMultipart() {
//getting name for the image
String name = editText.getText().toString().trim();
//getting the actual path of the image
String path = getPath(filePath);
progress = ProgressDialog.show(this, "Subiendo imagen",
"Por favor, espere...", true);
//Uploading code
try {
String uploadId = UUID.randomUUID().toString();
//Creating a multi part request
new MultipartUploadRequest(this, uploadId, Constants.UPLOAD_URL)
.addFileToUpload(path, "image") //Adding file
.addParameter("name", name) //Adding text parameter to the request
.setNotificationConfig(new UploadNotificationConfig())
.setMaxRetries(2)
.startUpload(); //Starting the upload
} catch (Exception exc) {
Toast.makeText(this, exc.getMessage(), Toast.LENGTH_SHORT).show();
}
} …Run Code Online (Sandbox Code Playgroud) 我在头文件中声明了一个CGFloat变量:
@property (nonatomic)CGFloat *heightOfSection;
Run Code Online (Sandbox Code Playgroud)
在我的实现文件上合成它,但它给我一个错误,试图为它分配一个值:
// Set height of section
heightOfSection = 45.0f;
Run Code Online (Sandbox Code Playgroud)
这是显示的错误:
Assigning to 'CGFloat *' (aka 'float *') from incompatible type 'float'
Run Code Online (Sandbox Code Playgroud)
有什么想法来解决这个问题吗?
我在我的应用程序中创建了一个名为的新类EmpresasTableViewController,并在我复制CategoriasViewController到EmpresasTableViewController 的故事板中,我只想将类分配EmpresasTableViewController到EmpresasTableViewController故事板中,但名称EmpresasViewController不会出现在Identity Inspector.
创建类后没有错误,但为什么它没有在故事板Identity Inspector下显示为Custom Class?,显示所有其他视图控制器.
我正在开发一个新的Android项目.
第一个活动是使用滑块菜单和片段.在第一个片段上有一个列表视图(PrimaryFragmentDormir.java).选择其中一行后,将启动一个新活动.最后一个活动使用三个选项卡,以显示有关所选行对象的不同信息.listview是从远程JSON文件加载的.第一个选项卡显示有关所选对象的详细信息,第二个选项卡应显示地图.
我已按照官方文档设置了在我的应用中包含Google地图所需的所有内容,至少我是这么认为的.当用户选择第二个选项卡时,会显示一个空白屏幕,左下方有Google徽标.
这是Android Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.solinpromex.elpasojuarezexperience" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
<uses-library android:name="com.google.android.maps"/>
<application
android:name=".app.AppController"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="..hidden here..." />
<activity
android:name=".Inicio"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
</activity>
<activity
android:name=".Detalle_Hotel"
android:label="@string/title_activity_detalle__hotel" >
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
这是托管标签的主要活动:
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; …Run Code Online (Sandbox Code Playgroud) 这是我使用JSON从MySQL表中检索数据的代码:
//URL definition where php file is hosted
int categoriaID = [[categoriaDescription objectForKey:@"idCategoria"] intValue];
NSString *string = [NSString stringWithFormat:@"%d", categoriaID];
NSLog(@"CATEGORIA ID STRING %@",string);
NSMutableString *ms = [[NSMutableString alloc] initWithString:@"http://mujercanariasigloxxi.appgestion.eu/app_php_files/categoriaslist.php?id="];
[ms appendString:string];
// URL request
NSLog(@"URL = %@",ms);
NSURLRequest *request = [NSURLRequest requestWithURL:ms];
//URL connection to the internet
[[NSURLConnection alloc]initWithRequest:request delegate:self];
Run Code Online (Sandbox Code Playgroud)
记录的URL是正确的,但应用程序抛出异常:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString absoluteURL]: unrecognized selector sent to instance
Run Code Online (Sandbox Code Playgroud)
我猜错误应该在上面的代码中,但我不明白为什么.欢迎任何帮助.
在我的Android应用中,我在一个扩展Fragment的类中显示了一个Google Maps地图.
目前,只显示地图,但我无法从SupportFragmentManager获取地图.
我所做的是将Android Studio中的MapActivity调整到我的应用程序.
这是我的代码:
public class Tab2 extends Fragment {
private GoogleMap mMap; // Might be null if Google Play services APK is not available.
private double latitud_del_hotel, longitud_del_hotel;
private String nombre_del_hotel;
private GoogleMap map;
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.tab_2, container, false);
//setUpMapIfNeeded();
return v;
}
@Override
public void onActivityCreated(Bundle state) {
super.onActivityCreated(state);
setUpMapIfNeeded();
}
private void setUpMapIfNeeded() {
// Do a null check to confirm that …Run Code Online (Sandbox Code Playgroud) 我正在使用一个片段来显示带有项目的回收视图。
我有一个用于 recyclerview 的 Adapter 类。
每次用户单击 recyclerview 项目时,我都需要更改片段 TextView 中的文本。
这是适配器类中的 onClick 方法:
@Override
public void onClick(View v) {
int position = getAdapterPosition();
//showPopupMenu(v, position);
String positi = marcaList.get(position).getnombre();
Integer positid = marcaList.get(position).getId();
Log.d("HOLA PERFIL", "RESPONSE 2 valor=" + position);
Toast.makeText(mCtx,"Seleccionados dispositivos de la marca "+positi, Toast.LENGTH_SHORT).show();
SharedPreferences prefs3 =
mCtx.getSharedPreferences(MISDATOS, Context.MODE_PRIVATE);
SharedPreferences.Editor editor3 = prefs3.edit();
editor3.putString("nombreMarcaNuevoDisp",positi);
editor3.putInt("idMarcaNuevoDisp",positid);
editor3.apply();
}
Run Code Online (Sandbox Code Playgroud)
我需要的是使用所选列表项中的值更新片段中 TextView 中的文本。
编辑
适配器类别:
public class MarcasAdapterNuevoDisp extends RecyclerView.Adapter<MarcasAdapterNuevoDisp.ProductViewHolder> {
public static String MISDATOS= "MisDatos";
private Context mCtx; …Run Code Online (Sandbox Code Playgroud) ios ×5
android ×4
google-maps ×2
objective-c ×2
cgfloat ×1
cocoa-touch ×1
core-data ×1
java ×1
multipart ×1
nsurlrequest ×1
storyboard ×1
swift ×1
tabs ×1
uitableview ×1
upload ×1
xcode ×1