我有一个应用程序,显示不同文件的表视图.我已将其设置为异步下载,并希望所选单元格显示进度条.我整个下午都在网上看过,到目前为止我发现的一切似乎都不完整,如何做到这一点.这是我目前为止下载的代码,并设置为具有progressview show下载状态.
码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
RSSEntry *entry = [_allEntries objectAtIndex:indexPath.row];
NSURL *url = [NSURL URLWithString:entry.articleUrl];
self.nameit = entry.articleTitle;
NSURLRequest *theRequest = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60];
receivedData = [[NSMutableData alloc] initWithLength:0];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self startImmediately:YES];
}
- (void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
progress.hidden = NO;
[receivedData setLength:0];
expectedBytes = [response expectedContentLength];
}
- (void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[receivedData appendData:data];
float progressive = (float)[receivedData length] / (float)expectedBytes; …Run Code Online (Sandbox Code Playgroud) 我正在尝试从表格视图切换到详细视图.当我点击单元格时它会崩溃.我已经使用了休息来尝试找到它崩溃的代码,但我找不到特定的行.当从表视图到详细视图执行segue时,它会崩溃.我想将一些变量传递给详细视图但我首先需要让它切换到详细视图.我正在使用故事板fyi.任何帮助,将不胜感激.
更新:崩溃日志如下
arg c = (int) 1
arg v = (char **) 0x2fd63cdc
Run Code Online (Sandbox Code Playgroud)
这就是崩溃的路线
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
Run Code Online (Sandbox Code Playgroud)
更新2
当我逐步完成代码时崩溃之前的最后一段代码就是为segue函数做准备.在那里的最后一行代码之后它崩溃并转到上面的一行.
更新3
我意识到控制台已被隐藏,因此这是控制台中显示的错误.我的两个准备segue的nslog都被调用了.
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<DetailViewController 0x1e098bd0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key name.'
*** First throw call stack:
(0x3a1e63e7 0x39072963 0x3a1e60d5 0x3a418fe9 0x3a414d53 0x3a16c8a5 0x39665d7d 0x396655ff 0x3955e039 0x394e8421 0x3953d1b7 0x3953d0fd 0x3953cfe1 0x3953cf0d 0x3953c659 0x3953c541 0x3952ab33 0x3952a7d3 0x3958b2ad 0x3960dca1 0x3a4b9e67 0x3a1bb857 0x3a1bb503 0x3a1ba177 0x3a12d23d 0x3a12d0c9 0x3746633b 0x3951d291 0x69a9 …Run Code Online (Sandbox Code Playgroud) 我得到这样的TableView:
TableView tableView = (TableView) ((AnchorPane) node).getChildren().get(0);
Run Code Online (Sandbox Code Playgroud)
用它填充数据
tableView.setItems(FXCollections.observableList(vehicles));
Run Code Online (Sandbox Code Playgroud)
这部分还可以.但是,我想更改tableView中当前行的字体属性,我无法知道如何操作
我不想设置,tableView.getSelectionModel().setCellSelectionEnabled(true);因为我想显示整行的选择,而不是单个单元格
我尝试在TableRow和Tabliew上应用一些CSS样式但没有任何成功.
有没有办法在TableView中更改当前所选行的字体属性?
我在Oracle文档中遵循了关于TableView的教程,我想做同样的事情,但是我想展示一个RadioButton,而不是显示TextField来修改项目.(我用RadionButton创建了TableView)
我正在创建一个应用程序,我将获取用户的电话簿并将其显示在列表视图中.我将电话簿分成按名称排序的部分.我希望按偶数和赔率交替行如果问题是indexPath.row如果新部分开始则重置为零.我试图得到它在我尝试的部分的奇怪或甚至行AGNOSTIC
- (void)tableView:(UITableView *)tableView
willDisplayCell:(UITableViewCell *)cell
forRowAtIndexPath:(NSIndexPath *)indexPath
{
if(switcher == 0)
{
switcher = 1;
}
else
{
switcher = 0;
}
}
Run Code Online (Sandbox Code Playgroud)
希望每次显示新单元格时偶数选择器都会改变.这几乎可以工作,但有时如果我停止并再次开始滚动我将获得零两次或一次两次(它不完美).
先感谢您![我为当前结果添加了一张图片,为期望的结果添加了另一张图片![] [1]](https://i.stack.imgur.com/ryk12.png)
目前我正在使用这种方法的类.
class TipInCellAnimator {
// placeholder for things to come -- only fades in for now
class func animate(cell:UITableViewCell) {
let view = cell.contentView
view.layer.opacity = 0.1
UIView.animateWithDuration(0.1) {
view.layer.opacity = 1
}
}
}
Run Code Online (Sandbox Code Playgroud)
并在我的主viewcontroller中调用它,如下所示
override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell,
forRowAtIndexPath indexPath: NSIndexPath) {
TipInCellAnimator.animate(cell)
}
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是,当重新加载项目时,单元格会闪烁,因为它正在淡入,我无法点击屏幕来停止滚动.
有没有人有关于如何解决这些问题或其他方法达到相同效果的一些提示?
通过拖动拖放区中的列,默认Javafx表可以对多个字段进行排序吗?
我的用户需要选择一个或多个列以对不同的列进行排序。该应用程序完全使用Java8和JavaFX编写。
我现在使用的源代码是:
import java.util.Collections;
import java.util.Comparator;
import java.util.function.Function;
import javafx.application.Application;
import javafx.beans.property.SimpleObjectProperty;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.Dragboard;
import javafx.scene.input.TransferMode;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class GroupByTable extends Application {
public enum Color { GREEN, BLUE, RED }
public enum Shape { RECTANGLE, CIRCLE, TRIANGLE }
public enum Size { SMALL, MEDIUM, LARGE }
private Label groupByLabel;
private Comparator<Item> groupingComparator ;
@Override
public void start(Stage primaryStage) {
TableView<Item> table …Run Code Online (Sandbox Code Playgroud) 我有JavaFX TableViewUI更新的问题.更改可观察对象后,它不会更新UI TableView.但是,如果我执行一个神奇的仪式,TableView再次向下拉动滚动条 - 它似乎重绘了表格并更新其中的项目.通过调试,我确保了PreferencesSet ArrayList和对象的正确更新.
这是我第一次在这里提问,所以我可能遗漏了一些重要的信息.随意问我这个问题.先感谢您.
这是代码(我遗漏了不相关的东西):
ControllerClass:
public class TestSomethingController implements Initializable {
public TableView<PreferenceValues.PreferencesSet> preferencesTable;
public TableColumn mdColumn;
public TableColumn typeColumn;
public TableColumn tradeColumn;
public TableColumn plastColumn;
public TableColumn capColumn;
public TableColumn multColumn;
public TableColumn sizeColumn;
@Override
public void initialize(URL location, ResourceBundle resources) {
setNorthPanel();
setTableColumns();
fillAllInfo();
}
private void setTableColumns() {
mdColumn.setCellValueFactory(new PropertyValueFactory<PreferenceValues.PreferencesSet, MarketDirection>("md"));
typeColumn.setCellValueFactory(new PropertyValueFactory<PreferenceValues.PreferencesSet, UserOfferType>("type"));
tradeColumn.setCellValueFactory(new PropertyValueFactory<PreferenceValues.PreferencesSet, Boolean>("trade"));
plastColumn.setCellValueFactory(new PropertyValueFactory<PreferenceValues.PreferencesSet, Long>("plast"));
capColumn.setCellValueFactory(new PropertyValueFactory<PreferenceValues.PreferencesSet, Double>("cap"));
multColumn.setCellValueFactory(new PropertyValueFactory<PreferenceValues.PreferencesSet, Double>("mult"));
sizeColumn.setCellValueFactory(new PropertyValueFactory<PreferenceValues.PreferencesSet, …Run Code Online (Sandbox Code Playgroud) 我要尝试使用KYDrawerController或SWRevealViewController侧栏菜单.但是有一个问题,每个人都给出了一个相同viewcontroller的例子.当我按下tableView上的单元格并保留侧栏菜单时,我想更改viewcontroller.这是我第一次使用侧栏菜单.我猜这就是为什么我没有得到主要想法,我不能这样做.如果你给我一个想法或样品,我会很感激.
我在TableView中有一个UILabel,并且UILabel附加到GestureRecognizer。我想做的是在标签点击时将UILabel的颜色更改为红色。现在,当我轻敲UILablel时,我非常接近,Label变为红色,但是错误的TableCell改变了颜色。如果我点击单元格3,那么我希望单元格3中的UILabel更改颜色,而不是单元格4或5。
class HomeProfilePlacesCell: NSObject {
var CellCopy: HomeTVC?
@objc func PostTap(_ sender: UIGestureRecognizer) {
// This works but it often changes wrong cell
CellCopy?.post.textColor = UIColor.red
}
func HomeProfilePlaceTVC(_ tableView: UITableView, cellForRowAt indexPath: IndexPath, streamsModel : streamModel,HOMEPROFILE: HomeProfile, controller: UIViewController) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "HomeTVC", for: indexPath) as! HomeTVC
CellCopy = cell
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(PostTap(_:)))
tapGesture.delegate = self as? UIGestureRecognizerDelegate
cell.post.addGestureRecognizer(tapGesture)
cell.post.text = streamsModel.Posts[indexPath.row]
cell.post.tag = indexPath.row
return cell
}
}
Run Code Online (Sandbox Code Playgroud)
再次,代码可以正常工作,我只需要找到一种方法即可将单击的单元格的索引路径传递到PostTap方法,以便它可以更改所点击的正确单元格的颜色。任何帮助或建议都会很棒。我不想使用“表刷新”,因为我仅在单击的单元格中更改了1个UILabel。